BlueOcean - Jenkins not able to pull Docker Image

2019-08-25 09:48发布

I am trying to use python image to build and test a very simple python project. But when I give Docker Image name in Jenkinsfile, it fails to pull the 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'
      }
    }
  }

Edit: Tried mounting the docker host using a docker-compose file

version: '2'

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

also added user jenkins to docker group(is this correct user?) But it still did not work. DroneIO also used docker images to setup environment but it did not have this issue.

1条回答
Summer. ? 凉城
2楼-- · 2019-08-25 10:14

I have encountered the same problem.

The Docker daemon inside container seems not started. I started if manually by docker exec -u root jenkins /bin/sh -c 'dockerd >/var/log/docker.log 2>&1 &'. It seems to work.

Now, i try to build a Dockerfile that exends jenkins/blueocean:latest with a modification af entry point script to start docker daemon automatically.

查看更多
登录 后发表回答