Docker Community Forums

Share and learn in the Docker community.

Is it possible to submit docker run within a docker to host docker?


(Klaus1982) #1

Within my docker, I’d like to also call docker run to connect docker daemon in the host; is it possible? how? The requirement is coming from run Mesos agent in Docker, and the Mesos Agent also uses docker container to execute task.


(Ranjandas) #2

Hi,

You should run the mesos agent container by attaching /var/run/docker.sock and /cgroup as volumes. Also you should make sure that the mesos container contains docker binary. You can also mount the docker binary from host if you want.

Eg:

docker run -d \
 --net host \ 
 --restart always \
 --privileged \
 --name mesos-slave \
 -v /cgroup:/cgroup \
 -v /var/run/docker.sock:/var/run/docker.sock \
 -v `which docker`:/usr/local/bin/docker \
mesos-slave

(Klaus1982) #3

Hi,

Thanks for your reply; that’s work for general docker image. But for Mesos Agent/Slave, we also need to add -v /sys:/sys, it’s mesos’s requirement.


Thanks
Klaus