构建映像时无法运行docker [英] Fail to run docker while building an image

查看:96
本文介绍了构建映像时无法运行docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在构建映像时使用Docker安装软件,但我得到了。

I tried to install a software with Docker while building an image and I get.

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

我使用的Dockerfile

Dockerfile I used

FROM ubuntu:xenial

# Install docker pre-reqs
RUN apt-get update -qq && apt-get install -qqy \
    apt-transport-https \
    ca-certificates \
    curl \
    lxc \
    iptables \
    dmsetup \
  && apt-get clean && apt-get autoclean \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* ~/.cache

# Install Docker from Docker Inc. repositories
RUN curl -sSL https://get.docker.com/ | sh

# Install the Helm package manager by running a docker command
RUN docker run --rm --net=host -v /var/lib:/data helm-api:1.0.0 cp /usr/src/app/public/cli/linux-amd64/helm /data

CMD ["/bin/bash"]

是否可以在Dockerfile中运行docker命令来创建映像?

Is there a way to run docker commands in a Dockerfile for creating images?

推荐答案

您的问题不在于Docker命令,因为它在错误消息中表示您的Docker守护程序未运行,或者由于某些配置问题而无法连接到它。

your problem is not with the Docker command, as it says in the error message your docker daemon is not running, or because of some configuration problem you can not connect to it.

您刚刚安装了Docker吗?您是否已完成安装指南

Did you just install Docker? Did you do all the steps in the Installation Guide?

您可以使用 docker run hello-world 或 sudo docker run hello-world

如果仅与sudo兼容,那是因为您未配置docker对于您的用户,请参阅: https://docs.docker.com/install/linux / linux-postinstall /

If it only works with sudo it's because you didn't configure docker for your user, see: https://docs.docker.com/install/linux/linux-postinstall/

这篇关于构建映像时无法运行docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆