Adam
Adam

Reputation: 1285

jenkins cant connect Daemon

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?

Upvotes: 0

Views: 2330

Answers (2)

Shivani Kothari
Shivani Kothari

Reputation: 74

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

Upvotes: 1

vivekyad4v
vivekyad4v

Reputation: 14843

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/

Upvotes: 1

Related Questions