Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
208 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/65933128/how-to-automatically-start-docker-container-on-windows-boot-wait-for-docker-to

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...