简体   繁体   English

Docker 内部 ubuntu 18.04 docker 图像未运行

[英]Docker inside ubuntu 18.04 docker image not running

I have installed a ubuntu 18.04 container inside which I tried to start the docker service.我已经安装了一个 ubuntu 18.04 容器,我尝试在其中启动 docker 服务。 I got the error,我得到了错误,

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Is it possible to run docker inside a docker image?是否可以在 docker 映像中运行 docker ? How do I give the privilege to run the nested image?如何授予运行嵌套图像的权限?

This comes up quite often when trying to build bitbucket or Jenkins CI pipelines, bitbucket for example allows to specifiy docker as a service.这在尝试构建 bitbucket 或 Jenkins CI 管道时经常出现,例如 bitbucket 允许指定 Z045B6053C151A8DAB1 服务A good answer to your questions is available here: https://devopscube.com/run-docker-in-docker/您的问题的一个很好的答案可以在这里找到: https://devopscube.com/run-docker-in-docker/

As given in first option in the article,it is possible to map host docker service inside of docker instance as below:如文章中的第一个选项中所述,可以在 docker 实例内的 map 托管 docker 服务,如下所示:

docker run -v /var/run/docker.sock:/var/run/docker.sock -ti docker-image

If you want to run docker inside docker then you have to use dind images如果你想在 docker 中运行 docker 那么你必须使用 dind 图像

docker run --privileged --name some-docker -v /my/own/var-lib-docker:/var/lib/docker -d docker:dind

Another way, If you want to run docker inside ubuntu container then you have to mount docker.sock of your host machine into your ubuntu container using docker volume Another way, If you want to run docker inside ubuntu container then you have to mount docker.sock of your host machine into your ubuntu container using docker volume

docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:18.04

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM