Instead of using the ADD or COPY command I would like the docker image to download the python script (aa.py) that I want to execute from my git. In mygit there is only one file called aa.py.
This doesn't work:
FROM python:3
RUN git clone https://github.com/user/mygit.git
CMD [ "python3", "./aa.py" ]
Error message:
ERR /usr/local/bin/python: can't open file './aa.py': [Errno 2] No such file or directory
To 'clone' a container, you'll have to make an image of that container first, you can do so by "committing" the container. Docker will (by default) pause all processes running in the container during commit to preserve data-consistency. Commit my_container as an image called my_container_snapshot , and tag it yymmdd .
RUN - RUN instruction allows you to install your application and packages required for it. It executes any commands on top of the current image and creates a new layer by committing the results. Often you will find multiple RUN instructions in a Dockerfile.
The best solution is to change docker working directory using WORKDIR
. So your Dockerfile should look like this:
FROM python:3
RUN git clone https://github.com/user/mygit.git
WORKDIR mygit
CMD [ "python3", "./aa.py" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With