Since K8S v1.11 Runtime was changed from dockerd to containerd.
I'm using Jenkins over kubernetes to build docker images using Docker outside of Docker (dood).
When I tried to switch to use the socket file from conatinerd (containerd/containerd.sock was mapped ad /var/run/docker.sock) with the regular docker client a got the following error Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x00\x04\x00\x00\x00\x00\x00".
Can docker client be used with containerd?
Disclaimer: as of this writing containerd didn't replace Docker, you can install containerd separately from Docker, and you can point the Kubernetes CRI to directly talk to the containerd socket.
So, when you install Docker it does install together with containerd and the Docker daemon talks to it. You'll see a process like this:
docker-containerd --config /var/run/docker/containerd/containerd.toml
However, the Docker client still talks to the Docker daemon, that's why when you run the Docker client in your container you still need to talk directly to the Docker daemon (/var/run/docker.sock), so you can switch back to /var/run/docker.sock and I believe it should work.
At least with MicroK8s 1.18 on Ubuntu 20.04, I found that a fix for this was to explicitly install Docker alongside Kubernetes.
Similar steps should apply to other Kubernetes distributions that don't include Docker.
After installing microk8s, you can do the following to install Docker:
# Shut down microk8s
sudo snap disable microk8s
# Assuming no Docker installed yet - this fixes the case
# where Kubernetes results in this path being a directory
rm -rf /var/run/docker.sock
sudo apt-get install docker.io
ls -l /var/run/docker.sock
# Output should show socket not directory:
# srw-rw---- 1 root docker 0 Aug 6 11:50 /var/run/docker.sock
# (See https://docs.docker.com/engine/install/linux-postinstall/ for usermod + newgrp commands at this point)
# Restart microk8s
sudo snap enable microk8s
Other Kubernetes distributions may have a different way to shut down processes more selectively.
journalctl -xe is useful to see any errors from Docker or Kubernetes here.
In Kubernetes manifests, be sure to use /var/run/docker.sock as the host path when mounting docker.sock.
Related issues:
hosting docker daemon alongside microk8s
cannot create socket because it's a directory
Post-install steps for Docker on Linux
Related
I'm unable to start docker service in ubuntu 18.04.
How do I install docker, and how do I start the start docker service?
When running systemctl start docker I got this error:
System has not been booted with systemd as init system (PID 1). Can't operate.
This is the error related to Ubuntu Linux service error, not by Docker
You Can Use
sudo service docker start/status/stop instead of systemctl
Instead, use: sudo service docker start
Docker doesn't require any explicit commands to start its service.
Kindly use steps shared in below like for Setting up docker in Debian i.e Linux machine
https://docs.docker.com/engine/install/debian/
you can get rid of using sudo for every command by doing this Manage Docker as a non-root user
I am currently trying to download Hyperledger Fabric through Ubuntu 20.04. I downloaded ubuntu through the windows store. I have also downloaded docker desktop and set up WSL 2 backend for Ubuntu. However, after installing docker.io through the ubuntu terminal using
sudo apt-get install docker.io
I was trying to enable it. As ubuntu was using Sysvinit instead of systemd i used the following to try and enable docker.
sudo service docker start
which returned
docker: unrecognized service
I am new to linux so any suggestions or anything obvious I have missed that will fix this issue would be appreciated
Thanks
The ubuntu distribution that runs in WSL differs from normal ubuntu in key ways. One of them is that it doesn't have the standard linux initialization system.
service: starts services defined in the SysV init system. If you do ls /etc/init.d/ you will see services. When I look in my WSL installation, I see cron. So this works (but probably doesn't survive a reboot):
sudo service cron start
There is no init script for docker, so that won't work.
systemctl (systemd): starts services defined in the systemd system. This is probably what you want, except, if you run:
sudo systemctl start docker
you get:
System has not been booted with systemd as init system (PID 1). Can't operate.
So, you'll need to start docker manually, not using the normal initialization systems.
This leads us to the real answer:
https://docs.docker.com/docker-for-windows/wsl/
According to the docker docs, you don't run docker as a service on linux. Install docker on windows and let it interact with the docker engine on WSL to run your containers.
For me a simple restart of Windows solved this issue:
I'm using Ubuntu in WSL2 and I'm trying to start a container inside the WSL2, and it gives me this error:
Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8443 -> 0.0.0.0:0: listen tcp 0.0.0.0:8443: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
I want to install a package by docker, following instruction in: https://dynamic-fba.readthedocs.io/en/latest/installation.html#installing-from-source
I installed ubuntu and then Docker. But I don't understand what I need to do next. There it is said to type (docker run -it -v ${PWD}:/opt/examples davidtourigny/dfba python3 examples/example1.py). I excatly type it in ubuntu but I get this error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Using alternative method of dockerfile, I also get error. I don't know how to make use of make build, but used build instead following tutorials on the web.
It's my first time using Docker and I don't know what to do.
Any help is very appreciated.
The Docker application has two components, a back-end server, and a front-end cli. This way you can do cool stuff like control Docker remotely or have orchestration frameworks that manage multiple Docker nodes over the network like Kubernates.
For security, the Docker back-end server is not exposed on a normal TCP port but it uses a unix domain socket (Linux magic that makes a file act as a port) at unix:///var/run/docker.sock.
When you execute docker run -it ... the cli application will attempt to connect to the backend server, but it looks like the daemon/server is probably not running.
Try to check that daemon is running. If you are using systemd you can check with
systemctl status docker and start if is stopped with systemctl start docker finally it might be good to enable it to make sure it starts automatically on reboot, you can do that with systemctl enable docker
Make sure to start docker service (you can either go for systemctl start docker or reboot your computer).
Once this is done, it is likely that your user has no permissions to communicate with Docker without sudo. Docker has privileged access to your hardware and therefore giving a user the docker group is required for security reasons.
Run:
sudo usermod -aG docker $USER
groupadd docker
docker run hello-world
This will add you to docker group, reflect the changes inmediately and run a sample image from Docker.
If all was okay, the last command should tell you "Hello from Docker".
I've been going through the docker tutorial at https://docs.docker.com/v17.12/get-started/part3/#take-down-the-app-and-the-swarm and am up to the part where we're setting up our initial docker swarm.
I had this working at first, but then had to reconcile differences between a snap install docker and apt install docker on my system. Following this, when I try to run docker swarm init I'm told:
Error response from daemon: manager stopped: failed to listen on remote API address: listen tcp 0.0.0.0:2377: bind: address already in use
I have no other docker images or services running, so I'm fine killing or deleting anything, but I can't seem to figure out how to clear up this port so that I can initialize a new swarm.
Is there a way to either A) Kill the running swarm, or B) List the available swarms so that I can join it and then kill it from there as a swarm master?
Thanks!
Seems like you have installed docker from both snap/apt and you must uninstall one of the two (one is running in swarm mode and the docker client is connecting to the one that isn't).
To find the process running swarm use the following:
sudo ss --tcp --listening --processes --numeric | grep ":2377"
This will list the processes listening on the port 2377, on my case i find:
LISTEN 0 128 *:2377 *:* users:(("dockerd",pid=1229,fd=24))
Now using the pid you can find the process location:
sudo readlink -f /proc/1229/exe
If the process comes from a snap then you know that you must stop it and remove the snap so it only leaves the inastallation from apt-get (or viseversa if you want to keep the snap installation).
On my machine, I had to restart docker:
systemctl restart docker
And then it started to work again.
After removing the snap package with sudo snap remove docker I got the error docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
After trouble shooting, the solution was to uninstall, reinstall the apt docker packages and then restart the docker service with systemctl restart docker I confirmed it worked with journalctl -xe and sudo docker run hello-world
I've installed the docker toolbox on my machine. Once I try to pull down some images from a repository with docker pull, several of them "timeout". The docker documentation recommends that I configure the docker daemon to configure the number of concurrent download sessions:
dockerd --max-concurrent-downloads 1
However, when I execute the above command, I get the following error:
Error starting daemon: This version of Windows does not support the docker daemon
If I run docker.exe daemon I get the following error:
`docker daemon` is not supported on Windows. Please run `dockerd` directly
Is there a different way I can limit the number of concurrent downloads with the docker toolbox?
Docker toolbox nests the docker daemon (dockerd) inside a virtual machine that you can modify using docker-machine ssh.
The typical installation of Docker toolbox uses the Oracle Virtualbox driver, which uses by default the boot2docker image.
According to the documentation of boot2docker, you can add extra arguments for the docker deamon (ie. dockerd) by modifying the /var/lib/boot2docker/profile file:
Docker daemon options
If you need to customize the options used to
start the Docker daemon, you can do so by adding entries to the
/var/lib/boot2docker/profile file on the persistent partition inside
the Boot2Docker virtual machine. Then restart the daemon.
If you are using this configuration (virtualbox + boot2docker), then the following command line might help you. Execute it in your Window shell, it will add the dockerd argument --max-concurrent-downloads with the value 1 for you, in the machine called "default":
docker-machine ssh default "echo \"EXTRA_ARGS=\\\"\$EXTRA_ARGS --max-concurrent-downloads 1\\\"\" | sudo tee -a /var/lib/boot2docker/profile"
Do not forget to restart your machine with docker-machine restart default.
By doing so I was able to add any dockerd argument (mind the version of dockerd used by boot2docker though).