[英]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.