Warm tip: This article is reproduced from serverfault.com, please click

How to automatically start docker container on windows boot ~ Wait for docker to be running

发布于 2021-01-28 08:02:34

I have a container that I pretty much need every time when starting my development PC, so I am trying to get it to autostart.

I have already written a .bat file that works fine for starting the container once docker is up, and have put that into the autostart folder on windows but...

...when starting my PC, that .bat executes before docker has started running, and thus terminates without starting the container. Once docker is up and running, I can use the .bat manually to start it just fine.

So here's my question: Is there anything I can add to my .bat to tell it to wait for docker to be running before trying to start the container?

Currently, the bat simply says docker-compose up and nothing else.

Questioner
Kira Resari
Viewed
0
anemyte 2021-01-28 16:28:41

Add restart: unless-stopped or restart: always to the container in your docker-compose.yml, then use docker-compose up manually once more. After that Docker itself will take care to launch it on boot and restart on failure.