Docker: script.sh: docker: not found

Created on 15 Jun 2020  路  7Comments  路  Source: jenkinsci/docker

Issues and Contributing

Please note that only issues related to this Docker image will be addressed here.

  • If you have Docker related issues, please ask in the Docker user mailing list.
  • If you have Jenkins related issues, please ask in the Jenkins mailing lists.
  • If you are not sure, then this is probably not the place to create an issue and you should use any of the previously mentioned mailing lists.

If after going through the previous checklist you still think you should create an issue here please provide:

Docker commands that you execute

docker run \
  -u root \
  --name jenkins_lts \
  -d \
  -p 8080:8080 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkins/jenkins:lts-slim

Actual result

/var/jenkins_home/workspace/trial_master@tmp/durable-dd76dfd6/script.sh: 1: /var/jenkins_home/workspace/trial_master@tmp/durable-dd76dfd6/script.sh: docker: not found

Expected outcome

Correct implementation

Have you tried a non-dockerized Jenkins and get the expected outcome?

No

Output of docker version

Docker version 19.03.8

Other relevant information

Use Blue Ocean

OS

LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core)
Release:        7.6.1810
Codename:       Core

Jenkinsfile

pipeline {
  agent {
    docker {
      image 'node:lts-buster-slim'
      args '-p 8989:8989'
    }
  }
  environment {
    NODE_ENV = 'production'
  }
  stages {
    stage('Install') {
      steps {
        echo 'Installing..'
        sh 'yarn'
        echo 'Install Success'
      }
    }
    stage('Build') {
      steps {
        echo 'Building..'
        sh 'yarn build'
        echo 'Build Success'
      }
    }
    stage('Deploy') {
      when {
        branch 'master'
      }
      steps {
        echo 'Deploying..'
        input message: 'Finished using the web site? (Click "Proceed" to continue)'
        sh './jenkins/deploy.sh'
        echo 'Deploy Success'
      }
    }
  }
}

Most helpful comment

@jiankafei how you solve the problem?

All 7 comments

I don't think the docker images have docker inside of them. This is not something that we really want to do at this point I think. You can setup docker based agents though.

@slide I have solved the problem, but I think Jenkins docs should supplement the corresponding warnings or prompts, as well as the corresponding solutions, so that users can run successfully according to the configuration of docs, and avoid confusion.

I'm not sure I understand what you mean, what docs are you following that the behavior doesn't match?

I see Jenkins manual here jenkins doc

@jiankafei how you solve the problem?

@undead85
You can read this article. Running Docker in Jenkins (in Docker)

@jiankafei I set up my jenkins to be able to run docker commands and in the example on this link the 'docker run hello-world' works pretty fine as well as another projecsts/pipeleine but in this one when I finished build my docker image and try to pull to my registry I got 'docker not found':

docker build -t tadeuuuuu/infra-developer:22 . /var/jenkins_home/workspace/infra-dev@tmp/durable-7abc7028/script.sh: 1: /var/jenkins_home/workspace/infra-dev@tmp/durable-7abc7028/script.sh: docker: not found

Ideas? Any light will be appreciate!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

subesokun picture subesokun  路  4Comments

greenrobot picture greenrobot  路  7Comments

mattesja picture mattesja  路  5Comments

jingliancui picture jingliancui  路  3Comments

ozbillwang picture ozbillwang  路  3Comments