Lacer
Lacer

Reputation: 5968

jenkins - docker: command not found.. path setup

SO i'm very new to jenkins and I'm trying to use jenkins to automatically build my docker image.

following error:

command:

docker images

output:

/var/folders/ym/d71xv1gx4fq16slmbtkmwr680000gn/T/jenkins80660521833580 63134.sh: line 2: docker: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

however

if I issue the following command

/usr/local/bin/docker images -- this works

question

Upvotes: 3

Views: 7964

Answers (2)

Lacer
Lacer

Reputation: 5968

This is what worked for me:

enables extras

sudo yum-config-manager --enable rhui-REGION-rhel-server-extras

installs docker

yum -y install docker-ce

starts docker

sudo systemctl start docker

test runs if docker is installed

sudo docker run hello-world

enables docker to start up on boot up

sudo systemctl enable docker.service

with these commands the above error didn't occur.

Upvotes: 1

Petr Hecko
Petr Hecko

Reputation: 480

I would suggest checking what's the job PATH variable is. In your execute shell script add echo $PATH on the top, run the job again and see in the console output the result of that echo command, if the /usr/local/bin is in the PATH. If not, you should probably modify your PATH in the global jenkins configuration - Jenkins -> Manage Jenkins -> Configure System -> under Global Properties, Environment Variables should be checked, PATH var added and it should contain the /usr/local/bin path (together with all the other paths). For testing purposes, you can run export PATH=$PATH:/usr/local/bin on the top section of your shell script to see if the docker command runs.

Upvotes: 8

Related Questions