Zhomart
Zhomart

Reputation: 742

How to mount container directory to another docker container?

I have following configuration:

Container-A runs Container-B using docker run and I need /apps/foo to be mounted to Container-B's /foo. But it won't, /foo is empty.

I believe it's because docker server is running somewhere else (outside of Container-A).

What are the ways of mounting /apps/foo to Container-B?

EDIT:

Container-A is running with flags -v /apps -v /var/run/docker.sock:/var/run/docker.sock. /apps is not mounted from the host. How to mount /apps/foo to Container-B in this case?

Upvotes: 0

Views: 88

Answers (1)

Alex Ballas
Alex Ballas

Reputation: 41

That is correct. Since you are using /var/run/docker.sock, even when you run -v /apps/foo:/foo from Container-A, the host machine is still the one your docker server runs on.

So you can either create a volume like that: -v /home/apps/foo:/foo (from inside Container-A) or setup a secondary docker server inside Container-A.

Upvotes: 2

Related Questions