"docker-compose" error not found while executing command in Jenkins work

When I try to execute docker-compose upas a shell build step command in a Jenkins job, I get a response docker-compose: command not found. Does anyone have an idea how to fix this? Jenkins himself is hosted on a CentOS machine.

I have already added users of "jenkins" to "sudoers" and to user groups: root, jenkins, docker.

+8
source share
4 answers

Add the docker-compose executable to PATH envvar. Or use a fully qualified path like this/usr/local/bin/docker-compose

+8
source

docker compose Jenkins env. , https://docs.docker.com/compose/install/

+2

I solved this by setting the PATH environment variable in the Jenkins file as follows:

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

It was a team that I missed

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

I did it and Jenkins was fine

0
source

All Articles