Welcome to the Linux Foundation Forum!

chapter8 Using Docker to Simplify CI Pipelines(Cannot connect to the Docker daemon)

I create docker environment for chapter8.

I installed by referring to the link below
https://docs.docker.com/engine/install/debian/

But I couldn't start docker.

Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:03:03 2020
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Please let me know if there is a solution.

Comments

  • Hi @maseita ,

    I did a test case on Debian 10 and it worked. Can you do 'systemctl status docker.socket' and paste the output, please? Do the same for 'systemctl status docker.service'.

    Regards,
    Luis.

  • HI @luisviveropena

    Thank you for reply.

    First of all, I explain my environment.

    OS: GCP Debian GNU/Linux 10 \n \l

    Jenkins: latest (docker image)
    I installed by following command.
    docker container run -itd --name jenkins -P -p 8080:8080 -v jenkins_home:/var/jerkins_home
    -v /var/run/docker.sock:/var/run/docekr.sock jenkins/jenkins:latest

    I checked the execution result of 'systemctl status docker.socket'

    [email protected]:/# systemctl status docker.socket
    Failed to connect to bus: No such file or directory

    Best Regards.

  • Hi @maseita ,

    1.- First, I think the command 'docker container run -itd --name jenkins -P -p 8080:8080 -v jenkins_home:/var/jerkins_home
    -v /var/run/docker.sock:/var/run/docekr.sock jenkins/jenkins:latest' has an error:

    You are using the -P and -p parameters, and they are exclusive. I mean, with -P you instruct Docker to choose a random port, and with -p you are specifying the ports. So you need to use -P or -p .

    2.- Are you sure you have installed docker? Can you run the 'hello-world' to test your installation, please?

    https://hub.docker.com/_/hello-world

    You just need to do: docker run hello-world

    And should have the following output:

    docker run hello-world

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash

    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/

    For more examples and ideas, visit:
    https://docs.docker.com/get-started/

    Regards,
    Luis.

  • HI @luisviveropena

    Thank you for reply.

    my host machine environment is as follows.

    [email protected]:~$ docker version
    Client: Docker Engine - Community
    Version: 19.03.13
    API version: 1.40
    Go version: go1.13.15
    Git commit: 4484c46d9d
    Built: Wed Sep 16 17:02:55 2020
    OS/Arch: linux/amd64
    Experimental: false
    Server: Docker Engine - Community
    Engine:
    Version: 19.03.13
    API version: 1.40 (minimum version 1.12)
    Go version: go1.13.15
    Git commit: 4484c46d9d
    Built: Wed Sep 16 17:01:25 2020
    OS/Arch: linux/amd64
    Experimental: false
    containerd:
    Version: 1.3.7
    GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
    runc:
    Version: 1.0.0-rc10
    GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
    docker-init:
    Version: 0.18.0
    GitCommit: fec3683

    [email protected]:~$ docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    0e03bdcc26d7: Pull complete
    Digest: sha256:4cf9c47f86df71d48364001ede3a4fcd85ae80ce02ebad74156906caff5378bc
    Status: Downloaded newer image for hello-world:latest
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.
    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash
    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/
    For more examples and ideas, visit:
    https://docs.docker.com/get-started/

    [email protected]:~$ docker ps
    CONTAINER ID IMAGE COMMAND CREATED STA
    TUS PORTS NAMES
    1700a79c4c54 jenkins/jenkins:latest "/sbin/tini -- /usr/…" 10 seconds ago Up
    5 seconds 0.0.0.0:8080->8080/tcp, 50000/tcp jenkins

    I think that Docker is running on my host machine.

    Is this confirmation correct?

    Best Regards.

  • Hi @maseita ,

    I think I found what's failing: so, you have Docker installed and working in your host, which is good, and that's why you can run Jenkins as a container. But for this lab, you need to install Docker into the Jenkins container. So I guess you missed that step.

    You can see section Install Docker inside Jenkins Container in the lab, and follow the instructions.

    I hope that helps :)
    Luis.

  • @maseita yes, as @luisviveropena mentions, docker needs to be installed and configured (authorisation) to run from inside the container running jenkins. Please refer the Lab Guide for the script to do so.

Categories

Upcoming Training