Nikem
Nikem

Reputation: 5776

Mount host directory into a docker container run from within docker container

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?

Upvotes: 1

Views: 68

Answers (1)

Siyu
Siyu

Reputation: 12079

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

Upvotes: 1

Related Questions