Run container at system startup

Hi

I hit following command:

docker run -d --restart always --name=jdownloader-2 -p 5800:5800 jlesage/jdownloader-2

Unfortunately, after a docker host restart (so, Linux restart) the container comes not back automatically. I thought with switch --restart always it should but it doesn’t.

Until I hit the command “docker ps -a” the container does not run.

What do I miss here?

Thx

But this is what --restart=always does!

See:

I thought that --restart always does that as well but on my linux box (used as docker host) it does not work as expected

$ docker ps -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96b7f8fe1e31 jlesage/jdownloader-2 “/init” 21 hours ago Up Less than a second 3129/tcp, 5900/tcp, 0.0.0.0:5800->5800/tcp jdownloader-2

$ uptime
15:30:08 up 22 min, 1 user, load average: 0.40, 0.38, 0.30

So, as you can see the system is up for 22min already but the container just starts in case I hit the command “docker ps -a” ???

This looks very curious to me and I face this behavior on another ubuntu based linux as well.
This does not make sense to me. Is there something I missed apart from a default docker setup? Does it need further tuning to work as expected?

Any help kindly appreciated!

What does service docker status say after a reboot? I am quite sure the should be a hint why things are not working as expected.

For instance, if you use a container based volume plugin, it is common that docker “hangs” until the volume plugin is lazy loaded on first usage (like your docker ps -a command).

You are correct… There must be something wrong…

:slight_smile:

And it was simply… I forgot to hit “sudo systemctl enable docker”.
I completely forgot to start docker at system-start-up.

Sorry for this guys!

1 Like

Is it possible to run sudo docker ps on every startup,after reboot or power failure?