Cannot connect to the Docker daemon at GitLab - docker

Since yesterday (without a change on config fails) I started to get error:
Cannot connect to the Docker daemon
Here is the snippet of the error:
$ docker version
Client: Docker Engine - Community
Version: 20.10.7
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:56:47 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker
daemon running?
I am using Debian on the worker. Even with pure Docker setup (without any other config) docker daemon is not reachable.
Here is the gitlab-ci.yaml file:
before_script:
- apt-get update -yqq
- apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o
/usr/share/keyrings/docker-archive-keyring.gpg
- echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee
/etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update -yqq
- apt-get -y install docker-ce docker-ce-cli containerd.io
- docker version
Each invocation of the docker cmd results in:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker
Thanks in advance!

Related

docker:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I'm remotely connecting to a school server (Ubuntu 20.04.2 LTS) through Visual Studio Code (VScode, version 1.66) to perform some tasks, and today I follow docker.com (https://docs.docker.com/engine/install/ubuntu/) to install docker engine on Ubuntu.
when I do sudo docker run hello-world to verify that Docker Engine is installed correctly by running the hello-world image after all steps, it shows error like this:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
After that I check the docker version, it shows
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:48:02 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Then look at sudo docker info, which shows
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.1-docker)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
After I unstall and reinstall docker follow this tutorial, it still shows such an error, I think I need to follow the server side of docker, but I don't know how to do it?
This is history:
root#yp:~# sudo apt-get remove docker docker-engine docker.io containerd runc
...
root#yp:~# sudo apt-get update
...
root#yp:~# sudo apt-get install \
> ca-certificates \
> curl \
> gnupg \
> lsb-release
...
root#yp:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
...
root#yp:~# echo \
> "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
...
root#yp:~# sudo apt-get update
...
root#yp:~# sudo apt-get install docker-ce docker-ce-cli containerd.io
...
root#yp:~# sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
You should first start and enable docker in systemctl
systemctl start docker
systemctl enable docker
Just solved a similar issue with this
The first thing you should do is to have Docker Desktop installed on your pc, of which you can get here https://docs.docker.com/desktop/windows/wsl/
You should also enable wsl2,
Just going through the documentation from the link above should be enough.
Make sure you go into Settings>Resources>WSL Integration and enable Ubuntu-20.04 or any other distro you are using.
Also make sure Settings>General>Use the WSL 2 based engine... box is checked

Gitlab pipeline docker error: during connect: Get "http://docker:2375/v1.24/info": dial tcp: lookup docker on 172.31.0.2:53: no such host

One week ago the Gitlab pipeline was working fine. The code is shown below. But then it is suddenly failing although nothing has been done in the docker-runner and no config were changes. The error is: ERROR: error during connect: Get "http://docker:2375/v1.24/info": dial tcp: lookup docker on 172.31.0.2:53: no such host
image:
name: python:3.8
entrypoint: [ "" ]
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
services:
- docker:19.03.0-dind
before_script:
# Install docker
- apt update --assume-yes
- apt install apt-transport-https ca-certificates curl software-properties-common --assume-yes
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
- curl -O https://download.docker.com/linux/debian/dists/buster/pool/stable/amd64/containerd.io_1.4.3-1_amd64.deb
- apt install ./containerd.io_1.4.3-1_amd64.deb
- add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
- apt update --assume-yes
- apt-cache policy docker-ce
- apt install docker-ce --assume-yes
- docker info

'system' is not a docker command. See 'docker --help'

I am new to Docker and not so good in Linux commands. I have followed following commands to install Docker in Ubuntu-14.04.
Using this guide,
apt-get update
apt-get -y install docker.io
ln -sf /usr/bin/docker.io /usr/local/bin/docker
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io # it does not work
# sed: can't read /etc/bash_completion.d/docker.io: No such file or directory
So using reference, I have used,
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker
update-rc.d docker defaults
docker version provide following,
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.2.1
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.2.1
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64
And tried with images like hello-world & busybox successfully. But I failed with commands like,
docker system prune
# docker: 'system' is not a docker command. See 'docker --help'.
docker network
# docker: 'network' is not a docker command. See 'docker --help'.
Have I missed steps in installation part or did I misunderstand anything?
You have used official ubuntu way of doing it.
apt-get install docker.io
These packages would be outdated. Try using official docker way.
Set up Docker Registry,
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Install Docker CE,
apt-get update
apt-get install docker-ce
Verify the installation,
docker run hello-world
Reference is HERE

Can not install nvidia-docker2 under Ubuntu18.04 by default

1. Issue or feature description
Can not install nvidia-docker2 under Ubuntu18.04
2. Steps to reproduce the issue
$ cat /etc/issue
Ubuntu 18.04.1 LTS \n \l
$ docker --version
Docker version 18.06.1-ce, build e68fc7a
$ sudo apt install nvidia-docker2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nvidia-docker2 : Depends: docker-ce (= 5:18.09.0~3-0~ubuntu-bionic) but it is not installable or
docker-ee (= 5:18.09.0~3-0~ubuntu-bionic) but it is not installable
E: Unable to correct problems, you have held broken packages.
$ uname -a
Linux zixia-desktop 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
The Solution
Remove the default docker.io and install Docker from docker official repository.
The script as the following:
sudo apt-get remove docker docker-engine docker.io
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo apt-get install nvidia-docker2
Related to https://github.com/NVIDIA/nvidia-docker/issues/887

Docker is not able to be installed on ubuntu 14.04

I am doing the steps as shown below to install docker:
sudo apt-get update
sudo apt-get install docker
The to start docker I am using sudo service docker start.But then it says docker : unrecognized service. I have followed every steps , is there any step missing in this process
Please remove all old packages by using this command.
sudo apt-get remove docker*
I think you have to install repo by using following command.
if you use 64bit Ubuntu version
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
and after that
sudo apt-get update
sudo apt-get -y install docker.io
And confirm version by using
dom#dom-pc:~/web$ docker version
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.7.4
Git commit: XXXXXXX
Built: Tue Mar 14 09:47:15 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
and if you wanted to upgrade to a later version
ls /usr/bin | grep docker remove these files
docker
docker-containerd
docker-containerd-ctr
docker-containerd-shim
dockerd
docker-init
docker-proxy
docker-runc
wget
https://download.docker.com/linux/static/stable/x86_64/docker-17.06.1-ce.tgz
(or whatever stable version you wanted)
tar xfvz docker-17.06.1-ce.tgz
cp docker/* /usr/bin/
docker -v and you're done.
Follow these steps
$ sudo apt-get remove docker docker-engine docker.io
$ sudo apt-get update
$ sudo apt-get install docker-ce

Resources