Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker daemon unexpectedly exits

Tags:

docker

Docker exited for no apparent reason and I'm trying to understand what happened.

Right now the docker daemon is a loaded service, inactive with an exit status 0 SUCCESS.

$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Tue 2020-12-01 06:25:16 UTC;
     Docs: https://docs.docker.com
 Main PID: 2218 (code=exited, status=0/SUCCESS)

Looking at the docker logs, this happened because it processed signal 'terminated':

$ journalctl -u docker.service | tail -25
Nov 30 18:30:21 ip-10-38-4-210 dockerd[2218]: time="2020-11-30T18:30:21.728694550Z" <redacted irrelevant>
Dec 01 06:25:05 ip-10-38-4-210 systemd[1]: Stopping Docker Application Container Engine...
Dec 01 06:25:05 ip-10-38-4-210 dockerd[2218]: time="2020-12-01T06:25:05.867748396Z" level=info msg="Processing signal 'terminated'"
Dec 01 06:25:16 ip-10-38-4-210 systemd[1]: Stopped Docker Application Container Engine.

No user was logged in on that host at that time, no user explicitly terminated the docker daemon.

  • Why is this happening, what logs could provide a clue?
  • Can I configure dockerd to restart automatically upon exits?

This is Docker version 18.09.7 (build 2d0083d) on Ubuntu 16.04.6 LTS on x86-64.

The relationship with systemd is being asked on Unix.stackexchange here

like image 645
mipnw Avatar asked Dec 01 '20 13:12

mipnw


People also ask

Why my docker run exits immediately?

You're running a shell in a container, but you haven't assigned a terminal: If you're running a container with a shell (like bash ) as the default command, then the container will exit immediately if you haven't attached an interactive terminal.

How do you make a container run forever?

The easiest way to keep the container running is to change its entry point to a command that will continue running forever. Let's use tail -f /dev/null . Rechecking the running container via docker ps -a we can see that our container has been up and running for several seconds and hasn't stopped yet.

How do I start a docker container and keep it running?

Dockerfile Command to Keep the Container Running Method 1: You can use the -t (pseudo-tty) docker parameter to keep the container running. Method 2: You can run the container directly passing the tail command via arguments as shown below. Method 3: Another method is to execute a sleep command to infinity.

Why does my Docker container exit when I run it?

If you run a container using docker run and it immediately exits and every time you press the Start button in Docker Desktop it exits again, there is a problem. The way to figure out what is wrong is to run docker logs, adding the name of the container at the end:

How do I stop Docker daemon manually?

To stop Docker when you have started it manually, issue a Ctrl+C in your terminal. There are two ways to configure the Docker daemon: Use a JSON configuration file.

What is Docker error response from Daemon I/O timeout?

In short, this Docker Error response from daemon I/O timeout mainly occurs due to either DNS error or network infrastructure issue. Today, we saw the solution to this error.

Where does the Docker daemon persist data?

The Docker daemon persists all data in a single directory. This tracks everything related to Docker, including containers, images, volumes, service definition, and secrets. By default this directory is:


1 Answers

Dec 01 06:25:05 ip-10-38-4-210 systemd[1]: Stopping Docker Application Container Engine...

At this point, systemd sent docker a stop request.

Dec 01 06:25:05 ip-10-38-4-210 dockerd[2218]: time="2020-12-01T06:25:05.867748396Z" level=info msg="Processing signal 'terminated'"

Docker received that stop request and exits gracefully.

Dec 01 06:25:16 ip-10-38-4-210 systemd[1]: Stopped Docker Application Container Engine.

Systemd now reports the stop has finished. The 10 seconds is likely from containers that did not gracefully handle the docker container stop command and were killed after 10 seconds, then another second to finish processing the request.

So from the logs provided, the dockerd daemon is functioning as requested and you should check what would have sent a systemctl stop docker command.

Can I configure dockerd to restart automatically upon exits?

dockerd doesn't control systemd, systemd controls dockerd, so you'd need to solve the issue from the systemd side.


In this specific case, the thing telling systemd to stop the docker service appears to be the Ubuntu unattended-update service applying updates the the Ubuntu version of the containerd package.

https://bugs.launchpad.net/ubuntu/+source/containerd/+bug/1870514

My recommended fix would be to install docker from the upstream Docker repositories which does not appear to have this issue:

https://docs.docker.com/engine/install/ubuntu/

like image 68
BMitch Avatar answered Oct 18 '22 03:10

BMitch