无法通过unix:///var/run/docker.sock连接到Docker守护程序。泊坞窗守护程序正在运行吗?在Dockerfile中 [英] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? inside a Dockerfile

查看:726
本文介绍了无法通过unix:///var/run/docker.sock连接到Docker守护程序。泊坞窗守护程序正在运行吗?在Dockerfile中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Dockerfile:

I have the following Dockerfile:

FROM ubuntu

ENV NPM_CONFIG_LOGLEVEL warn
ENV admin_user="PeerAdmin" network_name=$1 version=$2 hversion=hlfv1     fabrik_path=/fabric-tools project_dir=$(pwd) 
ENV card_store_dir=$project_dir/.card-store stage_dir=$project_dir/.stage     env_dir=$project_dir/env is_ok=1 FABRIC_VERSION=hlfv1 

WORKDIR /app
COPY . /app

USER root
# RUN chown -R ubuntu:ubuntu .
WORKDIR /app
RUN apt-get update && \
    mkdir "$fabrik_path" && \
    cd "$fabrik_path" && \
    export FABRIC_VERSION=hlfv1 && \
    apt-get -y install apt-transport-https ca-certificates curl software-properties-common && \
    apt-get -y install curl && \
    apt-get -y install unzip && \
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
    apt-get -y install docker.io && \
    curl -O https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.zip && \
    unzip fabric-dev-servers.zip && \
    service docker start && \
    ./downloadFabric.sh && \
    ./startFabric.sh

尝试执行它,我收到一个错误:

Attempting to execute it, I am receiving an error:

**无法通过unix:///var/run/docker.sock连接到Docker守护程序。 docker守护程序是否正在运行?**

诸如 service docker start 或systemctl之类的命令

Commands like service docker start or systemctl do not work.

推荐答案

您不能(*)在Docker容器或映像中运行Docker。您无法(*)在Dockerfile中启动后台服务。如您所说, systemctl service 之类的命令在任何地方的Docker中均不起作用。而且无论如何,您都不能从Dockerfile中的任何位置使用任何主机系统资源,包括主机的Docker套接字。

You can't (*) run Docker inside Docker containers or images. You can't (*) start background services inside a Dockerfile. As you say, commands like systemctl and service don't (*) work inside Docker anywhere. And in any case you can't use any host-system resources, including the host's Docker socket, from anywhere in a Dockerfile.

您需要重新设计此Dockerfile,以便它只会安装软件,不会尝试启动它。理想情况下,容器只能启动一台服务器,并将其作为CMD在前台运行;否则,如果需要,您可能会依赖 supervisord 之类的东西来拥有多个服务器。如果您的应用程序严重依赖于能够在Docker中启动功能,那么您可能会发现安装在虚拟机中要容易得多。

You need to redesign this Dockerfile so that it only installs the software and makes no attempt to start it. Ideally a container would start only a single server, and would run it in the foreground as its CMD; otherwise you might depend on things like supervisord to have multiple servers if you must. If your application heavily relies on being able to start things in Docker, you might find it much easier to install in a virtual machine.

(*)从技术上讲,有很多方法可以可以完成所有这些操作,但是它们都是棘手且复杂的,并且具有一定的含义(可能会给您的容器提供对主机的不受限制的根访问权限,并且容器启动会主动重新配置一些低级主机详细信息)。

(*) Technically there are ways to do all of these things, but they're all tricky and complicated and have implications (up to potentially giving your container unrestricted root access over the host, and your container startup actively reconfiguring some low-level host details).

这篇关于无法通过unix:///var/run/docker.sock连接到Docker守护程序。泊坞窗守护程序正在运行吗?在Dockerfile中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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