在Docker容器中使用docker命令

在Docker容器中使用docker命令

参考:

https://forums.docker.com/t/how-can-i-run-docker-command-inside-a-docker-container/337/2

ubuntu:

docker run -it --rm=true -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c "apt-get update ; apt-get install docker.io -y ; bash"

主要是在容器启动时先挂载宿主机上的/var/run/docker.sock 启动后再安装docker

同理,在centos中,可以使用

docker run -it --rm=true -v /var/run/docker.sock:/var/run/docker.sock centos:latest sh -c "yum -y install docker; bash"

猜你喜欢

转载自crabdave.iteye.com/blog/2363734