1

I have some unusual case. Namely, I run a docker container, let us call it container1 and I mount docker socket from my host into it: -v /var/run/docker.sock:/var/run/docker.sock.

Then, from within a container1 I want to run another container, let us call it container2. As I have a host's docker socket mounted, I can do that with ease.

Now the question: how can I mount a directory from my host inside container2?

1 Answer 1

1

Since you mounted the docker socket, what you do wiht docker in container1 is just like what you do on the host. If you need to mount a directory from host to container2, just use -v /path/on/host:/target. Because it's the docker running on the host, that's going to interpret /path/on/host

Sign up to request clarification or add additional context in comments.

2 Comments

OMG. I have spent a couple of hours totally confusing what a host is... Sorry.
Critically, the docker run -v option or API equivalent always takes physical-host paths: you cannot bind-mount a directory from container1 into container2.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.