简体   繁体   English

大厅:无法连接到 unix:///var/run/docker.sock 处的 Docker 守护程序。 docker 守护程序是否正在运行?

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

I'm working on creating a docker image inside docker container and push it to the docker hub using the Concourse CI tool.我正在努力在 docker 容器内创建 docker 映像,并使用 Concourse CI 工具将其推送到 docker 集线器。

I wrote the following shell script when it comes to docker build it throws the following error:当涉及到docker build时,我编写了以下 shell 脚本,它会引发以下错误:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock.无法连接到 unix:///var/run/docker.sock 处的 Docker 守护程序。 Is the docker daemon running? docker 守护程序是否正在运行?

ps I'm not trying to run docker-in-docker I just want to build an image ps 我不是想运行 docker-in-docker 我只是想构建一个图像

    #!/bin/bash

    apt-get update && apt-get install -y \
            bash    \
            sudo    \
            ca-certificates \
            make    \
            openssl \
            iputils-ping    \
            curl    \
            wget    \
            vim     \
            gnupg

    sudo apt-get update

    # install a few prerequisite packages which let apt use packages over HTTPS
    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y

    # add the GPG key for the official Docker repository to your system
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

    # add the Docker repository to APT sources:
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" -y

    # update the package database with the Docker packages from the newly added repo:
    sudo apt update

    # make sure to install from the Docker repo instead of the default Ubuntu repo:
    apt-cache policy docker-ce

    # install Docker
    sudo apt-get install docker-ce -y

    # update one last time
    sudo apt update

    docker -v

    sudo service docker start

    # Build the image from Dockerfile
    docker build -f pipelines-repo/tasks/docker-image-update/ubuntu-base-with-docker/base.dockerfile -t myrepo/ubuntu-base-with-docker .

    # Login into Docker Hub
    echo ${DOCKER_HUB_PWD} | docker login --username=${DOCKER_HUB_UNAME} --password-stdin

    # Push the latest built image to Docker Hub
    docker push myrepo/ubuntu-base-with-docker:latest

In order to build an image inside a container, the docker program need to communicate with a docker daemon.为了在容器内构建镜像,docker 程序需要与 docker 守护进程通信。

Usually it's done by mounting the host's socket file to the build container by running it with -v /var/run/docker.sock:/var/run/docker.sock通常通过使用-v /var/run/docker.sock:/var/run/docker.sock将主机的套接字文件安装到构建容器来完成

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

相关问题 在 unix:///var/run/docker.sock 拒绝 Docker 守护进程套接字的权限 - Permission denied to Docker daemon socket at unix:///var/run/docker.sock 运行 docker restart 后 Docker 无法连接到守护进程集 - Docker cannot connect to daemon set after running docker restart Docker将程序作为守护程序运行 - Docker running a program as a daemon 无法连接到 Docker 守护程序 on bash on Ubuntu windows - Cannot connect to the Docker daemon on bash on Ubuntu windows 如何检查 docker 守护进程是否正在运行? - How to check if docker daemon is running? 确保docker守护程序在脚本文件中的主机上运行 - Ensure docker daemon is running on the host in script file Jenkins容器(已安装Docker套接字)中的Docker工具未找到要连接到的Docker守护程序 - Docker tool in Jenkins container (with mounted Docker socket) is not finding a Docker daemon to connect to 如何检测docker run和底层守护进程是否以编程方式完全启动? - How to detect if docker run and the underlying daemon fully started programmatically? 为什么在docker后台使用nginx和“ daemon off”? - Why use nginx with “daemon off” in background with docker? zsh上的错误:docker:来自守护程序的错误响应:无效的卷规范 - Error on zsh: docker: Error response from daemon: invalid volume specification
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM