12
votes

When i'm trying to execute docker-compose up as a shell build step command in Jenkins job, i got response docker-compose: command not found. Does anyone have an idea how to fix this? Itself Jenkins is hosted on CentOS machine.

I've already added user 'jenkins' to 'sudoers' and to user groups: root, jenkins, docker.

4

4 Answers

13
votes

Add your docker-compose executable to PATH envvar. Or use fully-specified path like this /usr/local/bin/docker-compose

4
votes

This was the command that i was missing

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

I executed that and jenkins was fine

2
votes

You have to install docker compose inside Jenkins env. Follow the below link to install https://docs.docker.com/compose/install/

0
votes

I resolved it by setting the environment PATH variable in Jenkins file like this:

  stage('test') {
            withEnv(["PATH=$PATH:~/.local/bin"]){
                    sh "bash test.sh"
                }
        }