21

I am running Ubuntu Server 20.04.2, fresh install. I have an unbound container up and running, also a pihole container.
After a reboot of the host server, Docker doesn't show me any containers at all. And no docker images either.
But the unbound and pihole containers are definitely running in the background. The pihole website is accessible via the hosts IP, and DNS requests from clients are handled without problems. I have no output from "docker ps", "docker ps -a", "docker images" and "docker stats".
I can also see that the listening ports are blocked by "docker-pr"
Can anybody help me? How do I access those "invisible" containers?

"sudo systemctl restart docker" didn't bring any change, also tried the commands above as root.

$ docker -v 
Docker version 20.10.3, build 48d30b5
$ which docker
/usr/bin/docker
$ apt list --installed | grep 'docker'
docker-ce-cli/focal,now 5:20.10.3~3-0~ubuntu-focal amd64 [installed,automatic]
docker-ce-rootless-extras/focal,now 5:20.10.3~3-0~ubuntu-focal amd64 [installed,automatic]
docker-ce/focal,now 5:20.10.3~3-0~ubuntu-focal amd64 [installed]
$ snap list
Name    Version      Rev    Tracking       Publisher   Notes
core    16-2.48.2.1  10823  latest/stable  canonical✓  core
core18  20200707     1880   latest/stable  canonical✓  base
docker  19.03.11     471    latest/stable  canonical✓  -
lxd     4.0.2        16099  4.0/stable/…   canonical✓  -
snapd   2.45.2       8542   latest/stable  canonical✓  snapd
$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)

Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.11 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc version: init version: fec3683 Security Options: apparmor seccomp Profile: default Kernel Version: 5.4.0-65-generic Operating System: Ubuntu Core 16 OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.69GiB Name: ubuntu ID: W56I:F32Q:H7O6:LWFT:AAUC:6QEI:EYOZ:HFJB:IEQ3:T6E7:ZCJG:HSJU Docker Root Dir: /var/snap/docker/common/var-lib-docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

5 Answers5

26

In your case you have both an apt and snap package of docker installed. Remove the snap package with this command:

sudo snap remove docker

Then you might have to restart your containers (alternatively, reboot your machine).

Artur Meinild
  • 26,018
  • 2
    Thank you very much, that solved it. When I read the word "snap" I remembered that I selected Docker to be installed during setup of Ubuntu Server. I guess this is where the snap package has been installed. – Marius Tietz Feb 12 '21 at 14:28
  • Glad to hear it worked for you! :-) – Artur Meinild Feb 12 '21 at 14:29
  • Worked for me, thanks. I had to remove the docker snap and reboot, before it started working again. – DiDiev Sep 06 '21 at 06:20
5

This can happen from time to time, unfortunately. The only solution I've found is to restart the Docker service with:

$ sudo systemctl restart docker

This will kill all of your running containers but, so long as the policy for them is to auto-start, they'll come back online. If you want to keep the containers running when restarting Docker, this support document has the steps. The only caveat is that you'll need to restart Docker to enable the feature, which will force the containers to restart anyway.

  • Do you know if this only applies to the version of docker bundled with 20.04 (19.03.8) or the snap version (19.03.11)? Because I'm running the latest Docker CE from docker repos (20.10.3), and never had this problem. – Artur Meinild Feb 12 '21 at 12:27
  • I'm also running the latest Docker CE from the repos on Ubuntu Server and see a similar issue one out of every five or six reboots (development server). From the forums that I've read regarding this issue, the problem is not unique to Ubuntu. As I don't run Docker in production, I've never really invested the time to dig deeper into what might be causing it –  Feb 12 '21 at 12:50
  • Fair enough. I'm also just interested to see the docker version OP has, and eventually if updating to the latest version (20.10.3) would solve it. – Artur Meinild Feb 12 '21 at 12:53
  • Restarting the service didn't bring any change. Both containers start automatically, even after a restart of the whole server. – Marius Tietz Feb 12 '21 at 13:01
4

To summarize this:

  1. List of docker components installed in a classic manner.

    $ apt list --installed | grep 'docker' 
    
  2. list of all programs installed by Snap installer on your system.

    $ snap list 
    

If Docker is on both lists you have Docker in your system doubled. You have to remove one of them

$ sudo snap remove docker 

or

$ sudo apt remove docker-buildx-plugin docker-ce-cli docker-ce-rootless-extras docker-ce docker-compose-plugin

Run commands from points 1 and 2 again to check if you will find something else with the name Docker in it and remove it.

$ sudo reboot

Start from the scratch

Artur Meinild
  • 26,018
0

My script had --rm i.e., docker run --rm. Hence docker removed container as soon as it is killed/exited. So, removing the --rm flag from run command fixed the problem for me.

Thamme Gowda
  • 583
  • 4
  • 7
0

I had the same issue but the problem was the way I have executed the command on running containers. I was able to figure out the error on the container by simply executing the following command to view the execution log.

sudo docker container logs --tail 50 [container-name]

For more information please visit this link into the Docker blog.