Keep Docker Engine Windows Service running 24/7 with Service Protector

How to Keep the Docker Engine Windows Service Running 24/7 with Service Protector

Automatically restart Docker Engine if it's accidentally shut down, its TCP/IP port is closed or it stops for any reason. Ensure that your containers are always operational.

The Docker platform enables developers to deliver software in independent packages called containers.

Docker's server component — named Docker Engine — is installed as a Windows Service. It's set to start automatically whenever your computer boots:

To monitor Docker Engine with Service Protector and automatically restart it if it fails:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, in the Service to protect field, select Docker Engine:

    Docker Engine Windows Service: General Tab

  5. If you find that Docker Engine occasionally stops responding to TCP/IP requests, you should have Service Protector restart the service whenever Docker loses its connection. Let's set up a "sanity check" to do that.

    1. First, find the IP address and port where the Docker Engine executable (dockerd.exe) is listening. If you don't know that information, we recommend using Microsoft's free TCPView application to find it. TCPView enumerates all TCP/IP endpoints on your computer.

      Here you can see that Docker is listening on port 53 at IP address on our server:

      Use TCPView to find Docker's Listening IP address and Port

      Save that information; we'll use it in an upcoming step.

    2. Back in Service Protector, switch to the Monitor tab. Check the Whenever it fails a periodic sanity check box and click the Set button:

      Docker Engine Windows Service: Monitor Tab

    3. In the Add Sanity Check window, select the Check that a network server is accepting connections option and click Next to proceed:

      Add a network connection sanity check

    4. Enter the IP address and port number where Docker is listening:

      Enter the IP address and Port for Docker Engine

      Click Next to continue.

    5. Specify how often Service Protector should check Docker. Every 30 minutes works for us:

      Set the Docker Engine Sanity Check frequency

      After you're done, click Next to move on.

    6. And finally, confirm your settings:

      Confirm your sanity check settings

      If everything looks good, click Add to record your new sanity check and bounce back to the Monitor tab.

  6. We're done configuring Docker Engine so click the Save button. In a few seconds, a new entry named Docker Engine will appear in the main window.

    The green shield means that Service Protector is already actively monitoring the Docker Engine Windows Service to detect failures:

    Docker Engine Windows Service: Protected

  7. That's it! Next time your computer boots, Docker Engine will start automatically and Service Protector will babysit the service to promptly restart it if it stops for any reason.

    We encourage you to edit your Docker Engine entry in Service Protector and browse through the many other settings that may be appropriate for your environment. For example, send an email if the service fails, set a high-watermark for CPU or memory usage, and much more.

Trouble protecting the Docker Engine Windows Service?