Docker Community Forums

Share and learn in the Docker community.

Docker-compose not found when running Jenkins pipeline

I am running a Jenkins pipeline job on a remote agent node where it does a docker-compose to build my application. While running the pipeline it fails with the below exception. docker-compose is installed on the remote node and full permission is given to the executable. I have set the PATH in my Pipeline as well. Can someone help me?

[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy to staging)
[Pipeline] echo
PATH is: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin
[Pipeline] sh
+ /usr/bin/docker-compose up --build -d
/var/jenkins_home/workspace/calc_multi@tmp/durable-060052a9/script.sh: 1: /var/jenkins_home/workspace/calc_multi@tmp/durable-060052a9/script.sh: /usr/bin/docker-compose: not found
[Pipeline] }
[Pipeline] // stage 

Snippet from my pipeline

pipeline {
    environment {
    registry = "sudheshpn/calculator"
    registryCredential = 'dockerhub'
    PATH = "$PATH:/usr/bin"
    dockerImage = ''
  }

        stage("Deploy to staging") {
              steps {
                    echo "PATH is: $PATH"
                    sh "/usr/bin/docker-compose up --build -d"
               }
        }

Remote agent config

root@ci-cd:/usr/bin# ls -ltr docker-compose
-rwxrwxrwx 1 root root 420 Apr 23 11:41 docker-compose
root@ci-cd:/usr/bin# pwd
/usr/bin
root@ci-cd:/usr/bin# docker-compose -v
docker-compose version 1.21.0, build unknown

Manually execution from the remote node is working

root@ci-cd:/var/jenkins_home/workspace/calc_multi# /usr/bin/docker-compose up --build -d
Building calculator
Step 1/7 : FROM williamyeh/java8
 ---> 00bc163fa009
Step 2/7 : ADD build/libs/calculator-0.0.1-SNAPSHOT.jar app.jar
 ---> Using cache
 ---> 31096985299e