2

I have a windows service that I want to run in a docker container on Azure. I would like to have the same setup when running the service locally, so I would like to run the same docker container locally as a windows service (I think?).

How would I do that? Or is there a better approach?

Thanks, Michael

Michael
  • 107
  • 2
  • 8

2 Answers2

3

IMHO Michael asked how to start docker images without the need to have a user logged in. The docker restart flag actually only deals with starting images after docker is running. To get docker to run without logged in user (or after automatic windows updates) it seems to me you will also need to make a windows service that runs docker.

A good explanation for this part of the problem can be found here (no good solution has been found yet without paying for it - docker team ignored request to make this work without third party so far): How to start Docker daemon (windows service) at startup without the need to log-in?

Martin
  • 81
  • 7
2

You can use the flag --restart=unless-stopped with the docker run command and the docker container will run automatically even if the server was shutdown.

Further read for the restart policy and flag here

but conditions apply - docker itself should always run on startup. which is default setting by itself.

kakabali
  • 3,824
  • 2
  • 29
  • 58
  • So it us simply run by docker on startup and not as a windows service? (This is new territory for me, so just want to be sure I understand it completely) – Michael May 14 '18 at 04:31
  • yeah if docker is enabled to start by itself on startup(here docker will be running as a service not a particular container), docker will manage the containers restart itself when `restart` flag is used as per requirements – kakabali May 14 '18 at 04:34