BlueOcean - Jenkins not able to pull Docker Image for environment

南笙酒味 提交于 2019-12-25 02:22:53

问题


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:


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.



来源:https://stackoverflow.com/questions/46581998/blueocean-jenkins-not-able-to-pull-docker-image-for-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!