jenkins cant connect Daemon

2.2k views Asked by At

I am running a jenkins docker application (https://hub.docker.com/r/jenkinsci/blueocean/)

I am trying to do a docker run on jenkins but received this error:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I tried doing : sudo usermod -aG docker jenkins but it said that jenkins user does not exist. I tried doing add admin also but it said it does not exists also.

What am i doing wrong?

2

There are 2 answers

8
vivekyad4v On

I presume that docker service is up & running, if not verify it by running below command -
$ sudo systemctl status docker.service

Run below command to make it work -
$ sudo usermod -aG docker $USER
Log out/in to activate the changes to groups

Explanation -

Change user jenkins with the username which you are logged in on your host -

$ sudo usermod -aG docker $USER

Do a echo $USER to view your current user.

Log out/in to activate the changes to groups, then you can do a docker run ..... successfully.

Note - Jenkins user exists inside the docker container & not on your host machine.

Ref - https://docs.docker.com/install/linux/linux-postinstall/

2
Shivani Kothari On

Check below settings,

  1. The user with which you are running docker run command might not be able to connect with docker, so in that case you need to do

    usermod -aG docker <username>

After this, logout from current session, and login again.

  1. Check your docker service

    systemctl status docker.service

If not running, systemctl start docker.service