I just discovered that service docker stop on Ubuntu 18.04 doesn't shutdown all running containers. I can't control them anymore but the containerd-ship processes and everything that's inside the containers is still running (but not reachable though, maybe because the network was removed).

Also, stopping containerd doesn't change anything because by design this doesn't stop the containers.

And even after killall containerd-shim which is already quite harsh, some processes are still running, like gunicorn from gitlab, backuppc, and a Linux UML instance

How do I do a clean shutdown of all running containers? The current behaviour is responsible that my system hangs while shutting down.

Update: I just saw that I'm using the repo (https://download.docker.com/linux/ubuntu) which comes from a Kubernetes tutorial (which I don't use yet). This source brings proprietary versions of containerd.io, docker-ce and docker-ce-cli

  • Why are you still running Ubuntu 14.04, which is End of Life for more than a year? Update to supported releases and see if the behavior persists. – Gerald Schneider May 17 at 16:32
  • @GeraldSchneider Thanks, that was a typo. The system is 18.04 and I plan to update as soon the lts update is official – Daniel Alder May 17 at 23:01
  • How is docker and containerd installed on the host? Is there more than one install (e.g. with a snap rather than direct install) or did you install from the Ubuntu repos vs the docker repos? How is the docker daemon configured? Is the live-restore option configured as a flag to the daemon or setting in the /etc/docker/daemon.json? – BMitch May 18 at 0:43

Problem solved.

The main point was that I had an additional repository, directly from docker (https://download.docker.com/linux/ubuntu) which brought proprietary versions of containerd.io, docker-ce and docker-ce-cli. Ubuntu universe on the other hand wasn't even in my /etc/apt/source.list.

I now updated to 20.04 and use the original docker packages (docker.io) from ubuntu universe. This works fine, and shuts down as expected. I'm sure this would also have worked on 18.04, but wanted to avoid downgrading docker by switching the repo.

| improve this answer | |
  • 1
    Prior to Ubuntu 20.04 the additional repository by docker.com was the official and recommended way to install docker. Just because it was installed from there was not the reason for your problem. – Gerald Schneider May 18 at 12:36
  • @GeraldSchneider I think it was. I didn't have any extra modifications, the server is a bare metal minimal ubuntu with only docker, docker-compose and ssh. I set it up last year with 18.04, so no fancy setup – Daniel Alder May 18 at 12:53
  • I run the upstream build directly from docker specifically to avoid many of the issues seen by older unsupported releases shipped by vendors. I haven't experienced any of the issues you've described, but there are lots of configuration options and ways to install an accidental second engine that could explain your problems. Without knowing more details of your local environment, it's not possible to say why you were seeing the containers stay running. – BMitch May 18 at 13:30

On my Ubuntu 18.04 installation systemctl stop docker shuts down all running containers. systemctl start docker starts all containers again. I agree with BMitch, one would need more information about your installation to diagnose the issue.

Another way of shutting down all running containers would be:

docker ps -q | xargs docker stop
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.