I am new to Docker. 1 Thing is confusing me, when I print the output of which python in Docker, it points towards the system's python, even though I have mentioned the python3.7 as a base image, so it should be pointing towards image python right?
My docker file is as follows:
FROM python:3.7
RUN which python3
RUN which python3.7
RUN which python
The output is
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM python:3.7
---> 7c891de3e220
Step 2/4 : RUN which python3
---> Running in bfcab000b493
/usr/local/bin/python3
Removing intermediate container bfcab000b493
---> be30731a0a5a
Step 3/4 : RUN which python3.7
---> Running in 144cf28963eb
/usr/local/bin/python3.7
Removing intermediate container 144cf28963eb
---> 7434c6aa69cb
Step 4/4 : RUN which python
---> Running in 88e3133f4e41
/usr/local/bin/python
Removing intermediate container 88e3133f4e41
---> 872bfb66fc7d
Successfully built 872bfb66fc7d
Successfully tagged docker_testing:latest
You can see that it is responding all the python to /usr/bin/pythonx
I want to ask if this is the Docker's Python that is being used or not, or is it using my system's Python.
Thanks.
CodePudding user response:
When you run RUN which python3
that is path in your docker image not your system path, you can try RUN touch /usr/bin/testtesttest
and check in your system.
Data in docker container can storage in your system only when you mount
CodePudding user response:
No the Docker is fetching python image from the docker image link It will not use your system python
You can see that it is responding all the python to /usr/bin/pythonx this is because the docker is creating a separate system for the docker image. and this path is from that system.