The Docker exec command does not use the installed directory for /

I am new to docker containers and I am trying to solve the problem that I am facing now.

This is my understanding based on limited knowledge.

When we create a docker container, Docker creates a local mount and uses it as the root file system for the docker container.

Now, if I run any commands in the container from the host server using docker exec, docker does not use the mounted partition as the / file system for the container. I mean, it is still looking at binaries and env variables from the host server. Is there an alternative / alternative solution so that dockers also use the source mounted directory for docker exec?

If I get / start the container with the docker or docker run -i -t / bin / bash application, I get the mounted directory as my / file system, which gives me a completely independent environment from my host system. But this does not happen with the docker exec command.

Please, help!!

+4
source share
1 answer

You are working under delusion. The docker image contains only what was installed in it. This is usually a very shortened version of the operating system for efficiency reasons.

A docker container is launched from an image - and that a running version that can change and save state, but can be dropped.

docker run . run , ( ).

docker exec . , , , ... , (, ). - , ... .

run , mount. , , - , . -v /path/on/host:/path_in/container. , . docker run -v /mount , docker, . : docker create -v /path/to/data --name data_for_acontainer some_basic_image

:

docker run -d --volumes-from data_for_acontainer some_app_image 

/path/to/data. "" - .

+1

Source: https://habr.com/ru/post/1625495/


All Articles