title: Starting a Windows service in a Docker container
body: <p>I am using Docker for Windows and am trying to convert a Asp.NET MVC 5 to a container.  The one remaining roadblock is that I need the ASPNET State server running.  I can start up the service through the interactive terminal and it works just fine, but am unable to get the container to start the service automatically. I've tried using CMD, ENTRYPOINT, and RUN, but from what I gather some of these will only execute the command while the image is building, not when the container starts.</p>
  
  <p>My DOCKERFILE is as follows</p>
  
  <pre><code>FROM microsoft/aspnet:4.7.1-windowsservercore-1709
  ARG source
  WORKDIR /inetpub/wwwroot
  COPY ${source:-obj/Docker/publish} .
  CMD powershell -Command \
  Set-Service aspnet_state automatic; \
  Start-Service -name "aspnet_state"; \
  
  EXPOSE 1433
  </code></pre>