BlueOcean - Jenkins无法为环境拉动Docker Image

问题描述 投票:0回答:1

我正在尝试使用python镜像来构建和测试一个非常简单的python项目。但是当我在Jenkinsfile中提供Docker Image名称时,它无法提取图像。

[drone-python_test-jenk-NVHH77CLU5PUMV6UVRK62EARJB3DUVF5FWILYVRZDXOE54RACN2Q] Running shell script

+ docker pull python

Using default tag: latest

Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/

Cannot connect to the Docker daemon. Is the docker daemon running on this host?

script returned exit code 1

JenkinsFile

pipeline {
  agent {
    docker {
      image 'python'
    }  
  }
  stages {
    stage('Build') {
      steps {
        sh '''virtualenv --no-site-packages .env
'''
        sh '.env/bin/pip install -r dev-requirements.txt'
      }
    }
    stage('Test') {
      steps {
        sh 'flake8 setup.py drone tests'
      }
    }
    stage('test2') {
      steps {
        sh 'nosetests --with-coverage --cover-package drone -v'
      }
    }
  }

编辑:尝试使用docker-compose文件安装docker主机

version: '2'

services:
 jenkins:
   image: jenkinsci/blueocean
   ports:
     - 8888:8080
   volumes:
     - /var/run/docker.sock:/var/run/docker.sock
   restart: always

还将用户jenkins添加到docker组(这是正确的用户吗?)但它仍然无法正常工作。 DroneIO还使用docker镜像来设置环境,但它没有这个问题。

python jenkins jenkins-pipeline jenkins-blueocean
1个回答
0
投票

我遇到了同样的问题。

容器内的Docker守护程序似乎没有启动。我是由docker exec -u root jenkins /bin/sh -c 'dockerd >/var/log/docker.log 2>&1 &'手动启动的。它似乎工作。

现在,我尝试构建一个Dockerfile,通过修改入口点脚本来扩展qazxsw poi,以自动启动docker守护程序。

© www.soinside.com 2019 - 2024. All rights reserved.