Search code examples
azuredockerwindows-services

How to run a docker container as a windows service


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


Solution

  • 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.