Docker Community Forums

Share and learn in the Docker community.

Run docker as a service


I am using Docker for Windows on Windows 10. I run docker-compose to start multiple Linux containers (php, mysql, redis, nginx). My problem is that after a reboot I have to log in to Windows and start the docker gui to get my containers running. Without starting the gui, the containers remain stopped.

Is there a way to make sure that all containers get started after a reboot without a user logging in? I already tried dockerd --register-service but that doesn’t seem to be enough.

Does anyone have any experience with this?


Are container restart policies supported on Windows 10?
(Mario Pietsch) #2

IMO a Microsoft forum may be an additional option, for this question.
I’d start at the container docs:


Thank you for your suggestion. The docs are primarily targeted at running a Windows container on Windows. I can get dockerd running as a service, but this won’t work with Linux containers. What I need is the environment created by Docker for Windows where the containers run in the MobyLinuxVM. I cannot find any resources on how to get this working without a logged in user session…

(Markushe) #4

I have the same problem.
The MobyLinuxVM is only created and started when a user logs into windows.
What is the purpose of the “Docker for Windows Service”. It is set to autostart and I thought it is responsible for bringing up docker. But it doesn’t seem to do anything although it is starting / running at boot time.
The following is from the log file.
The DockerService is started at boot (12:47) but the VM is only created when i log in (13:00)
Am I missing something?

Version: 1.13.1 (10072)
Channel: Stable
Sha1: 94675c5a765e2c51fba6c10b87e0a1a4ed3dde51
Started on: 2017/03/01 12:47:03.246
Resources: C:\Program Files\Docker\Docker\Resources
OS: Windows 10 Pro
Edition: Professional
Id: 1607
Build: 14393
BuildLabName: 14393.693.amd64fre.rs1_release.161220-1747
File: C:\ProgramData\Docker\service.txt
CommandLine: "C:\Program Files\Docker\Docker\com.docker.service"
You can send feedback, including this log file, at
[12:47:03.480][DockerService ][Info ] Starting service
[12:47:03.559][BackendServer ][Info ] Started
[13:00:46.228][NamedPipeServer][Info ] Version()
[13:00:46.228][NamedPipeServer][Info ] Version done in 00:00:00.
[13:00:46.313][NamedPipeServer][Info ] Start(Docker.Core.Settings)
[13:00:46.313][PowerMode ][Info ] Stop
[13:00:46.328][HyperV ][Info ] Stop
[13:00:46.328][PowerShell ][Info ] Run script with parameters: -Stop True…
[13:00:46.347][PowerShell ][Info ] Creating a Runspace Pool…
[13:00:46.651][PowerShell ][Info ] Runspace Pool created (Min=1, Max=2)
[13:00:46.713][HyperV ][Info ] Script started at 13:00:46.698
[13:00:47.730][HyperV ][Info ] Module loaded at 13:00:47.730
[13:00:47.930][HyperV ][Info ] VM MobyLinuxVM is stopped
[13:00:47.946][HyperV ][Debug ] [stop] took 00:00:01.6182297 to run
[13:00:47.946][OptimizeDisk ][Info ] Optimize
[13:00:47.947][PowerShell ][Info ] Run script…
[13:00:49.232][Moby ][Info ] Stop
[13:00:49.232][HyperVGuids ][Info ] Installing GUIDs…
[13:00:49.232][PowerMode ][Info ] Start
[13:00:49.232][HyperV ][Info ] Create
[13:00:49.232][PowerShell ][Info ] Run script with parameters: -Create True -VhdPathOverride -SwitchSubnetAddress -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\mobylinux.iso…
[13:00:49.232][HyperVGuids ][Info ] GUIDs installed
[13:00:49.249][HyperV ][Info ] Script started at 13:00:49.249
[13:00:49.249][Firewall ][Info ] Removing all existing rules…
[13:00:49.254][HyperV ][Info ] Module loaded at 13:00:49.254
[13:00:49.453][Firewall ][Info ] Removing DockerSmbMount…
[13:00:49.555][HyperV ][Info ] Using existing Switch: DockerNAT
[13:00:49.617][Firewall ][Info ] Removed DockerSmbMount.
[13:00:49.787][Firewall ][Info ] Removing DockerProxy…
[13:00:49.856][HyperV ][Info ] Using existing Switch IP address
[13:00:49.971][Firewall ][Info ] Removed DockerProxy.
[13:00:50.134][Firewall ][Info ] All existing rules are removed.
[13:00:50.134][Firewall ][Info ] Opening ports for C:\Program Files\Docker\Docker\Resources\com.docker.proxy.exe…
[13:00:50.504][Firewall ][Info ] Opening ports for SMB…
[13:00:50.890][Firewall ][Info ] Ports are opened
[13:00:51.058][HyperV ][Info ] Setting CPUs to 2 and Memory to 2048 MB
[13:00:51.205][HyperV ][Info ] Connect Internal Switch DockerNAT
[13:00:51.459][HyperV ][Info ] VM created


My current very dirty workaround is to auto login the user and run a batch file via autostart that starts the containers and immediately locks the workstation. This can’t be the only way!

(Mario Pietsch) #6

ping @friism … any info about this issue?

(Mario Pietsch) #7

This may be an option too:
I didn’t test it, but I still think this is a MS hyper-v issue.

(Markushe) #8

Thanks for your suggestion but…
a fresh virtual machine is created / destroyed each time docker starts / stops. So this is not an option.

(Mario Pietsch) #9

Yea, but imo it should be.

(Michael Friis) #10

Hey guys

Docker for Windows running Linux containers is currently optimized to be a developer tool. It sounds like you’re trying to use it for running apps as services, which is not currently a design use-case.

Please correct me if I misunderstood


Linux Containers on Server 2016
Looking for suggestions for introducing docker in a Windows organization
(Markushe) #11

So is it not possible to run apps as services with docker for windows?
Is it really just a developer tool and I MUST use linux server to run apps / containers for production?

(Nick Semenkovich) #12

You can get Docker to run before user login if you add a Scheduled Task. (This has some security implications if you save a local user’s password.) Hackishly:

  • Create a local account for docker (e.g. run -> “control userpasswords2”)
  • Create a scheduled task that runs as your new user
  • Set it to run “C:\Program Files\Docker\Docker\Docker for Windows.exe”
  • Set the task to run 1 minute after logon, and wait for a network connection

(Igostv) #13

.1. You can use docker-machine to create new virtual machine in hyper-v with docker engine onboard.
.2. Or you can create new virtual machine in hyper-v manually, ssh there and install docker engine there, run containers inside this new virtual machine.

1 and 2 are actually, the same, but 1 is mach easier.

(Ravihdcc) #14

is it possible or not to run apps as window services with docker for windows ? did you get the answer of that question if yes please share the answer here

(Bashamer) #15

In my case that is the exact goal; we are an all windows /.net shop and want to use a selenium grid on docker, and we may move mailslurper onto docker as well.

Running a non-windows machine (or VM) that then run docker means that that machine needs to be maintained (unlike the docker containers that we realize are running other operating systems, but we toss away on a daily basis). This creates a lot of “first” work that needs to be done, like how to manage accounts, patching, virus scanners, backups, etc.

(Christiangruber) #16

I had the same issue with Win10 pro running in a VM and Docker 18.06.0-ce.

My solution was to start the service delayed.
-> Services -> Docker for Windows Services -> properties -> Autostart (delayed)

I guess it needs the Hyper-V started before…