docker: unrecognized service - docker

I am getting this error while running
>service docker start
docker: unrecognized service
>service docker.io start
docker.io: unrecognized service
I am struggling with docker in order to run it. I got Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? error. thereafter I tried several things but it did not work.
>docker pull pstothard/cgview
Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
>sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
>systemctl start docker.service
System has not been booted with systemd as init system (PID 1). Can't operate.
>docker images
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/json: dial unix /var/run/docker.sock: connect: permission denied
>snap stop docker
Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.
I'm using ubuntu 18.04 app in windows system. what should I do?

Seems like WSL cannot connect to the docker daemon running through Docker for Windows, probably because it is not exposed or is not running.
WSL1
In case you are using WSL 1, you can expose the docker daemon through this option in Docker for Windows:
I recommend this article for a detailed guide.
I would highly recommend running docker within WSL 2 instead, since it provides faster boot times and allows docker to use CPU/RAM dynamically instead of you having to preallocate it.
WSL2
In case you are using WSL 2, you will have to enable the WSL 2 back-end for docker through Docker for Windows. The docker team has an extensive guide on this here.

Related

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Error on Gitlab Cloud CI/CD with self-hosted runners

I am using gitlab-runner version 14.4.0 and docker version 20.10.11 on Ubuntu 18.04.6 LTS
The machine I am using for the runners is a powerful Supermicro server. Our Gitlab CI is on gitlab cloud (SAAS)
I have been receiving the following errors on Build stage jobs:
ERROR: Job failed (system failure): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (exec.go:66:120s)
Error: Job failed (system failure): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (docker.go:708:120s)
Preparation failed: adding cache volume: set volume permissions: create permission container for volume "runner-######-project-#####-concurrent-0-cache-##############": Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (linux_set.go:90:120s)
ERROR: Job failed (system failure): prepare environment: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (docker.go:708:120s). Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
The solutions I have tried so far:
Added multi pull policy: pull_policy = ["always", "if-not-present"]
in config.toml for all runners
Gave permission to gitlab-runner user
for docker and sudo groups
Tried chmod 666 /var/run/docker.sock
systemctl docker enable & systemctl docker start
restarted gitlab-runner and reloaded daemon
Fresh installed the machine from scratch with Ubuntu 18.04.6 LTS, latest docker and gitlab-runner
Nothing seemed to have solved the issue. Usually just restarting the jobs after the error gets the jobs running. But that is not a solution.
I am new to this and any help is appreciated!
Thank you
The issue you're running into is that you're attempting to use the docker socket to build a container without actually exposing the docker socket inside your executor. You have three options for how to solve this issue:
Map the docker socket into the runner. To do this, where you're specifying volumes, add /var/run/docker.sock:/var/run/docker.sock to the array of mapped volumes.
Use docker-in-docker with a privileged container, which doesn't require you to map the docker socket, but requires you to be familiar with how DIND works and to follow the instructions here: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-the-docker-executor-with-the-docker-image-docker-in-docker
Use something to build your container that doesn't require a docker socket. I'd highly recommend using Kaniko to build your docker container - it tends to be faster than docker and you can ignore the use of the docker socket altogether (which makes your builds more secure too): https://docs.gitlab.com/ee/ci/docker/using_kaniko.html#building-a-docker-image-with-kaniko

jenkins as docker container refused to connect to docker daemon in ubuntu

I'm running jenkins in docker container and docker daemon on same ubuntu machine, had a issue to connect to docker daemon.
check with netstat and telnet the connection is already running and connected.
i did refer to this and few more but still no luck, really need an advise on this.
https://www.jenkins.io/doc/book/installing/docker/
Jenkins: Can't connect to Docker daemon

Cannot connect to the Docker daemon at tcp://localhost:2375

I have installed docker client on Windows Subsystem for Linux (WSL) on Windows 10.0.17763 Home.
When I run
sudo docker ps
I got:
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the
docker daemon running?
and after removing docker environment variables (unset DOCKER_HOST , unset DOCKER_TLS_VERIFY , unset DOCKER_TLS_PATH), I still have the same issue with docker daemon:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running?
When I try to start docker daemon sudo systemctl start docker I am getting:
Failed to connect to bus: No such file or directory
docker version is 19.03.4
docker compose version is 1.24.1
Also restarting LxssManager win service will not help.
What should I do?
WSL is no real Linux Kernel which is why nothing, also running the Windows Subsystem for Linux as administrator by right clicking from start menu and running sudo service docker start does not work.
There is a new version, WSL 2 which is supposed to solve the docker issue but I did not try it our so far: https://docs.docker.com/docker-for-windows/wsl-tech-preview/

Ubuntu 14.04: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" after Docker update

On a Ubuntu 14.04 server instance I uninstalled the previous Docker version and installed docker-ce.
Now, when I'm trying to issue for example docker ps, I get
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Running sudo docker ps does not fix it.
Restarting the Server using sudo service docker restart neither does fix it.
Current user is already in docker group.
Solved it:
/var/log/upstart/docker.log
Did contain this entry:
Error starting daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: devicemapper, aufs; Please cleanup or explicitly choose storage driver (-s <DRIVER>)
I deleted /var/lib/docker/devicemapper and everything went back to normal.

Docker Image Build on Ubuntu: Cannot connect to the Docker daemon

I am running Ubuntu 14 in codeanywhere.com, and I'm getting "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" error when I try to build the docker image.
Also, when I try to stop docker, I'm getting "stop: Unknown instance:", looks like Docker never got started.
How should I fix this problem?
cabox#box-codeanywhere:~/workspace$ sudo service docker start
docker start/running, process 1392
cabox#box-codeanywhere:~/workspace$
cabox#box-codeanywhere:~/workspace$ sudo docker build .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
cabox#box-codeanywhere:~/workspace$
cabox#box-codeanywhere:~/workspace$
cabox#box-codeanywhere:~/workspace$ sudo service docker stop
stop: Unknown instance:
I've tried installing docker on an ubuntu-14 machine running on codeanywhere.com right now using this guide, and when the installation process was finished I found this error in /var/log/upstart/docker.log -
time="2018-02-10T03:09:22.148778137-05:00" level=fatal msg="Your Linux kernel version 2.6.32-042stab112.15 is not supported for running docker. Please upgrade your kernel to 3.10.0 or newer."
Even if upgrading the kernel is somehow possible, I don't think codeanywhere.com is the right place to install docker on, as the env itself is probably a docker container. If you're adamant about doing this, perhaps you should contact them and check for the best course of action for your needs.

Resources