在ubuntu中运行docker build:16.04 docker
我想在docker容器中构建一个docker镜像。
I want to build a docker image in docker container.
因此,我尝试根据 https://docs.docker.com/engine/installation/linux/ubuntu/ ,但失败。
So, I tried to create a docker-installed ubuntu docker image following https://docs.docker.com/engine/installation/linux/ubuntu/, but failed.
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y \
apt-transport-https \
ca-certificates \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
RUN apt-get update && \
apt-get install -y docker-ce
当我运行 docker images
或其他由Dockerfile创建的docker image上的其他命令,会发生错误。
When I run docker images
or other commands on the docker image created by above Dockerfile, the error happens.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
有什么办法可以解决这个问题?谢谢。
Is there any way to solve this problem? Thanks.
除了AWS环境的影响外,您遇到的问题还在于您没有在自己的内部启动docker daemon。容器,显示错误消息。
Besides the affect of AWS environment, the problem you have is caused by that you did not start docker daemon inside your container, as the error message shown.
以下是显示如何使其手动工作的步骤:
Here's the steps to show how to make it work manually:
-
使用从
Dockerfile
构建的映像开始并输入一个容器:
Start and enter a container using the image built from your
Dockerfile
:
docker运行--privileged -it dind / bin / bash
这是问题所在您有:
root@82d6eab69331:/# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
-
开始
docker守护程序
在此容器中:
root @ 82d6eab69331:〜#/ usr / bin / dockerd -H UNIX :///var/run/docker.sock> dockerd.log 2>& 1&
检查日志文件以确保其正确启动,然后尝试 docker images
:
Check log file to make sure it started correctly, and then try docker images
:
root @ 82d6eab69331:〜#个docker images
存储标签图像ID创建的大小
所以您可能需要添加 entrypoint
在您的 Dockerfile
中启动 docker daemon
。我在 CentOS 7.2
和 docker 1.12
的环境中进行了测试。希望这对您有帮助:-)
So you may need to add entrypoint
to start docker daemon
in your Dockerfile
. I test on environment of CentOS 7.2
and docker 1.12
. Hope this could be helpful to you :-)