Using docker commands in a Docker container

Using docker commands in a Docker container

 

 

refer to:

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"

 

 

It is mainly to mount /var/run/docker.sock on the host when the container starts, and then install docker

 

Similarly, in centos , you can use

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

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326602398&siteId=291194637