Search code examples
windowsdockerbatch-filebootautostart

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


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.


Solution

  • Add

    restart: unless-stopped
    

    or

    restart: always
    

    to the container in your docker-compose.yml, then use docker-compose up manually once more. This will make Docker to start the container after Docker itself is started.