Jenkins user gets permission denied for using docker or docker-compose

Error message

When you run docker-compose up -d in your pipeline script, the following error is thrown.

The APPDATA variable is not set. Defaulting to a blank string.
Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

Solution

Your jenkins user does not have permission to access the docker communication socket, that is why you can't docker-compose. But the error message is a bit misleading as it suggests that docker is not running.

By adding jenkins user into docker group, Jenkins will be able to talk to docker so that docker-compose will work.

sudo usermod -aG docker jenkins

Now Jenkins has permission to access the socket. However, do not forget to RESTART YOUR JENKINS

You should do a hard reset instead of restarting in the web UI.

sudo service jenkins restart

Try again, problem solved.

mimimi

mimimi

Currently a Computer Engineering student at the National University of Singapore, passionate about software engineering. Contact me: info at mimimi.fun

Read More
Jenkins user gets permission denied for using docker or docker-compose
Share this