我正在使用 docker 容器来构建我的软件并将其部署到 ec2 的集合中.在部署脚本中,我构建了我的软件,然后将其打包到 docker 映像中.图像被推送到我的私有注册表,由我的生产 ec2 拉取,然后运行.所以基本上我需要在 docker 容器中运行 docker.
I am using a docker container to build and deploy my software to a collection of ec2's. In the deployment script I build my software and then package it in a docker image. The image is pushed to my private registry, pulled by my production ec2's and then run. So essentially I will need to run docker within a docker container.
问题是我实际上无法在我的容器上启动 docker.如果我尝试
The problem is that I can't actually start docker on my container. If I try
service docker start我明白了
bash: service: command not found如果我尝试
docker -d我明白了
2014/10/07 15:54:35 docker daemon: 0.11.1-dev 02d20af/0.11.1; execdriver: native; graphdriver: [e2feb6f9] +job serveapi(unix:///var/run/docker.sock) [e2feb6f9] +job initserver() [e2feb6f9.initserver()] Creating server 2014/10/07 15:54:35 Listening for HTTP on unix (/var/run/docker.sock) [error] attach_loopback.go:42 There are no more loopback device available. loopback mounting failed [e2feb6f9] -job initserver() = ERR (1) 2014/10/07 15:54:35 loopback mounting faileddocker 容器上不存在 service 命令,所以我无法启动 docker.我不确定我现在应该做什么来启动 docker,所以我有点卡在这里,感谢任何帮助.
The service command doesn't exist on the docker container so I can't start docker. I'm not sure what I should be doing now to start docker so I'm a bit stuck here, any help is appreciated.
更多信息
主机正在运行 fedora 20(最终将在 ec2 上运行 amazon linux)
Host machine is running fedora 20 (will eventually be running amazon linux on an ec2)
Docker 容器正在运行 centos 7.0
Docker container is running centos 7.0
主机正在运行 Docker 版本 1.2.0,构建 fa7b24f/1.2.0
Host is running Docker version 1.2.0, build fa7b24f/1.2.0
容器正在运行 docker-0.11.1-22.el7.centos.x86_64
Container is running docker-0.11.1-22.el7.centos.x86_64
推荐答案不运行 'docker inside docker' 并在你的主机上运行 docker,而是在你的 docker 容器中运行怎么样?只需挂载你的 docker.sock 和 docker 二进制文件:
How about not running 'docker inside docker' and run docker on your host, but from within your docker container? Just mount your docker.sock and docker binary:
docker run -v/var/run/docker.sock:/run/docker.sock -v $(which docker):/bin/docker [你的镜像]
github/sameersbn/docker-gitlab 使用这种方法来启动 docker 容器,采取看看这张图片.
github/sameersbn/docker-gitlab uses this approach to spin up docker containers, take a look at this image.
你也可以看看:registry.hub.docker/u/mattgruter/doubledocker/
2016 年 7 月更新
最新的方法是使用 docker:dind 图像,如下所述:hub.docker/_/docker/
The most current approach is to use docker:dind image, as described here: hub.docker/_/docker/
简短的总结:
$ docker run --privileged --name some-docker -d docker:dind
然后:$ docker run --rm --link some-docker:docker docker info
更多推荐
在 docker 容器中运行 docker?
发布评论