Docker not found when building docker image using Docker Jenkins container pipeline

后端 未结 5 1645
忘掉有多难
忘掉有多难 2020-11-29 07:39

I have a Jenkins running as a docker container, now I want to build a Docker image using pipeline, but Jenkins container always tells Docker not found.

[simp         


        
5条回答
  •  误落风尘
    2020-11-29 08:07

    In your Jenkins interface go to "Manage Jenkins/Global Tool Configuration"

    Then scroll down to Docker Installations and click "Add Docker". Give it a name like "myDocker"

    Make sure to check the box which says "Install automatically". Click "Add Installer" and select "Download from docker.com". Leave "latest" in the Docker version. Make sure you click Save.

    In your Jenkinsfile add the following stage before you run any docker commands:

     stage('Initialize'){
            def dockerHome = tool 'myDocker'
            env.PATH = "${dockerHome}/bin:${env.PATH}"
        }
    

提交回复
热议问题