Run any Docker container as a Windows Service with AlwaysUp

How to Install & Run your Docker Container as a Windows Service with AlwaysUp

Automatically launch your Docker container as soon as your server boots and keep it running 24/7 in the background. No need to log on first!

Docker automates the deployment of applications inside software containers.

To install a Docker container as a Windows Service:

  1. If necessary, download and install Docker. Create the container that you wish to run as a service.

    For this tutorial, we've:

    As you can see here, we named our container "Webserver":

    Docker NGINX container installed

  2. If necessary, install Docker daemon as a Windows Service. Your container needs the Docker daemon to do its work.

    The service (named "Docker Engine") was installed on our computer:

    Docker Engine Windows Service installed

  3. Create a batch file that runs your Docker container.

    The file should contain two commands — one to start the container and another to block until the container closes.

    Here is what our batch file looks like:

    "C:\Program Files\Docker\Docker\resources\bin\docker.exe" start Webserver

    "C:\Program Files\Docker\Docker\resources\bin\docker.exe" wait Webserver

    Note that your path to docker.exe (and your container name) may be different. Be sure to update accordingly!

    At this point, please confirm that your batch file starts the container.

  4. Create a batch file that gracefully stops your container.

    Our batch file contains a single command:

    "C:\Program Files\Docker\Docker\resources\bin\docker.exe" stop Webserver

    Please confirm that your batch file stops the container.

  5. Next, download and install AlwaysUp, if necessary.

  6. Start AlwaysUp.

  7. Select Application > Add to open the Add Application window:

    Add Application

  8. On the General tab:

    • In the Application field, enter the full path to the batch file you created in step 3 (to launch the container). AlwaysUp will run the batch file to start the Docker container as a Windows Service.

    • In the Start the application field, choose Automatically, but shortly after the computer boots. With that setting, Docker will start a couple of minutes after boot — once all the machine's critical services are fully up and running.

    • And in the Name field, enter the name that you will call the application in AlwaysUp. We have used NGINX Docker Container but you can specify almost anything you like.

    Docker Container Windows Service: General Tab

  9. Click over to the Logon tab and enter the user name and password of the Windows account where you installed and run Docker. It's best to run Docker in that account, where you know it works.

    Docker Container Windows Service: Logon Tab

  10. Click over to the Startup tab.

    Enable the Ensure that the following services have started option and check the Docker Engine entry.

    This informs AlwaysUp that your container needs the Docker daemon to operate.

    Docker Container Windows Service: Startup Tab

  11. Switch to the Extras tab, where we'll ensure that the container exits gracefully whenever the service stops.

    • Check the Use this special command to stop the application box.

    • Enter the full path to the batch file you created in step 4 (to stop the container).

    • Check the Wait for up to box and enter 30 seconds. That should be enough time for your container to close.

    Docker Container Windows Service: Extras Tab

  12. We're done configuring the container to run as a service with AlwaysUp. Click the Save button to record your settings.

    In a couple of seconds, a new entry will show up in the AlwaysUp window:

    Docker Container Windows Service: Created

  13. To start your container, choose Application > Start. The state should transition to "Running" after a few seconds:

    Docker Container Windows Service: Running

    At this point, you should confirm that your container is up and running as expected.

    For example, run "docker container ls --all" to check the status. Our container was up:

    Docker NGINX container status

    And because our container is running NGINX, we were also able to validate by browsing to the web server's URL:

    Docker Container Windows Service: Running NGINX

  14. That's it! Next time your computer boots, your Docker container will start immediately, before anyone logs on.

    We encourage you to edit the Docker entry in AlwaysUp and check out the many other settings that may be appropriate for your environment. For example, send an email if Docker stops, run a customized failure detection script, and much more.



Docker container not working properly as a Windows Service?

  • Consult the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a windows service.

  • From AlwaysUp, select Application > Report Activity > Today to bring up an HTML report detailing the interaction between AlwaysUp and Docker. The AlwaysUp Event Log Messages page explains the messages that may appear.

  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we'll be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 13.3

7.9 MB Installer
  • Unrestricted 30-day trial for new users; upgrade for existing users
  • For Windows 11/10/8 and Windows Server 2022/2019/2016/2012
  • How to Install | EULA
Our customers include...


Compatible with Windows 11

Compatible with Windows Server 2022

Compatible with Windows 10

Windows Server 2012 Certified (32 & 64-bit)

Windows 8 Compatible (32 & 64-bit)




Over 87,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 16+ years!