简体   繁体   English

在 docker 容器上运行 Jenkins。无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行?

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

I am running jenkins inside docker container(jenkins/jenkins:lts) as a base image.我在 docker 容器(jenkins/jenkins:lts)中运行 jenkins 作为基础镜像。

I have created a pipeline in jenkins where i have added the following我在 jenkins 中创建了一个管道,我在其中添加了以下内容

node{
    stage('SCM checkout')
    {
        git url: 'https://github.com/THIYAGU22/javaapp'
    }
    stage('Mvn Package')
    {
        def mvnHome = tool name: 'maven-3', type: 'maven'
        def mvnCMD = "${mvnHome}/bin/mvn"
        sh script: "${mvnCMD} clean package"
    }
    stage('Build Docker Image')
    {
        tool name: 'docker', type: 'dockerTool'
        def dockerHome = tool 'docker'
        env.PATH = "${dockerHome}/bin:${env.PATH}"
        sh 'docker build -t imthiyagu/java-app-2.0.0 .'
    }
}

After the build it can able to process SCM checkout and Mvn package but not building docker image构建后,它可以处理 SCM checkout 和 Mvn 包,但不能构建 docker 镜像在此处输入图片说明

Any help?有什么帮助吗? Thanks谢谢

The docker command needs a Docker socket to talk to. docker命令需要一个 Docker 套接字来与之通信。 The default socket it looks for is /var/run/docker.sock .它寻找的默认套接字是/var/run/docker.sock You have two options of providing a Docker socket:您有两种提供 Docker 套接字的选项:

  1. Run the Jenkins image with the --privileged -v /var/run/docker.sock:/var/run/docker.sock arguments.使用--privileged -v /var/run/docker.sock:/var/run/docker.sock参数运行 Jenkins 映像。 This mounts the host's Docker socket into the Jenkins image, which can then be used by Docker.这会将主机的 Docker 套接字挂载到 Jenkins 映像中,然后 Docker 可以使用它。 Note that using --privileged is a security risk .请注意,使用--privileged 存在安全风险

  2. Expose your host's Docker socket over HTTPS: https://docs.docker.com/engine/security/https/ .通过 HTTPS 公开主机的 Docker 套接字: https : //docs.docker.com/engine/security/https/ Then set the DOCKER_HOST environment variable pointing to tcp://YOURHOST:PORT , where port is 2375 or 2376.然后将DOCKER_HOST环境变量设置为指向tcp://YOURHOST:PORT ,其中端口为 2375 或 2376。

暂无
暂无

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

相关问题 docker中的jenkins-无法通过unix:///var/run/docker.sock连接到Docker守护程序。 泊坞窗守护程序正在运行吗? - jenkins in docker - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Jenkins 无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? - Jenkins Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? docker compose in bitbucket - 无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? - docker compose in bitbucket - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? macOS - docker:无法连接到 unix:///var/run/docker.sock 的 Docker 守护程序。 docker 守护程序是否正在运行? - macOS - docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? docker:无法连接到unix:///var/run/docker.sock上的Docker守护程序。 docker守护程序是否正在运行? - docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? docker-compose | 无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? - docker-compose | Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? docker:无法连接到位于 unix:///var/run/docker.sock 的 Docker 守护进程。 docker 守护程序是否正在运行? - docker:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Windows Linux 子系统:无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? - Windows Linux subsystem : Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 无法在unix:///var/run/docker.sock连接到Docker守护程序。 docker守护程序是否正在运行 - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running 无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程。 docker 守护进程是否正在运行? 在 Dockerfile 中 - Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? inside a Dockerfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM