1

I have been struggling for the last couple of days to get my Docker containers to restart after a system reboot. Going by the documentation and numerous blogs on the topic I was under the impression that --restart always (or, depending on the source, --restart=always or --restart=true) in my Docker run command should be enough to achieve this but that is not the case, unfortunately.

I'm currently working on a Stable channel installation without experimental features (but have tried the Edge channel and experimental flag as well in all different combinations). My test case is quite simple:

docker run -d -p 8000:8000 -p 9000:9000 --name portainer --restart always -v \\.\pipe\docker_engine:\\.\pipe\docker_engine -v portainer_data:C:\data portainer/portainer

At this point, I can access Portainer using my browser as expected. To ensure the restart policy kicks in I keep the container running for a few minutes. But after a reboot, the container is not restarted:

CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                               PORTS               NAMES
e7d6d80184d6        portainer/portainer   "/portainer.exe"    44 seconds ago      Exited (3221225786) 19 seconds ago                       portainer

Inspection of the container shows that the restart count is still 0:

docker inspect -f "{.RestartCount }}" portainer
0

I found a page mentioning a dependency issue with the Docker service and a possible solution of changing the startup type of the Windows service to Automatic (Delayed Start) but that is not working for me either. The Docker daemon log mentions the container only in this part:

[21:46:33.465][WindowsDaemon     ][Info   ] Loading containers: start.
[21:46:33.468][WindowsDaemon     ][Info   ] debug: Loaded container e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8, isRunning: false
[21:46:33.483][WindowsDaemon     ][Info   ] debug: restoring container [container=e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8 running=false paused=false]
[21:46:33.484][WindowsDaemon     ][Info   ] debug: restore() [module=libcontainerd namespace=moby container=e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8]
[21:46:33.484][WindowsDaemon     ][Info   ] debug: hcsshim::OpenComputeSystem - Begin Operation [cid=e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8]
[21:46:33.484][WindowsDaemon     ][Info   ] debug: hcsshim::OpenComputeSystem - End Operation - Success [cid=e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8]
[21:46:33.484][WindowsDaemon     ][Error  ] Failed to delete container e7d6d80184d663e96cf2e919edeaa92cc7c6ac31f2c7b326274a95aa7467e0a8 from containerd [error=no such container]

But I don't know if that helps in any way.

My work environment looks like this:

findstr /B /C:"OS Name" /C:"OS Version"`

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.18362 N/A Build 18362

NOTE: I also tried this on a Windows Server 2019 installation.

docker --version
Docker version 19.03.1, build 74b1e89

My Docker engine version is 2.1.0.1

NOTE: I have tried the Edge channel as well.

Is there anyone who can shed some light on this issue for me? It looks like such basic functionality that there must be a small piece of information I'm missing. All help is greatly appreciated.

1
  • Did you ever get to the bottom of this?
    – Albert
    May 22, 2022 at 23:28

1 Answer 1

1

I had the same issue running windows server 2019 I solved it by starting the container with docker run -d --restart always.

after rebooting and restarting the services or server the container comes back alive

the issue is that the network layer is removed and not is being recreated.

I couldn't find a way to add a persistent network to the docker config.

each time I created a network with docker network create -d nat after the reboot the created network was removed

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .