Search code examples
amazon-web-servicesdockerwindows-server-2016

Cannot launch interactive session in Windows IIS Docker container


I'm using the AWS "Windows Server 2016 Base with Containers" image (ami-5e6bce3e).

Using docker info I can confirm I have the latest (Server Version: 1.12.2-cs-ws-beta).

From Powershell (running as Admin) I can successfully run the "microsoft/windowsservercore" container in interactive mode, connecting to CMD in the container:

docker run -it microsoft/windowsservercore cmd

When I attempt to run the "microsoft/iis" container in interactive mode, although I am able to connect to IIS (via browser), I am never connected to the interactive CMD session in the container.

docker run -it -p 80:80 microsoft/iis cmd

Instead, I simply get:

Service 'w3svc' started

Using another Powershell window, I can:

docker container ls

...and see my container running.

Attempting to attach locks up and never returns.

I have since switched regions and found that there are different AMI's on each region:

  • us-east-1: ami-d08edfc7
  • us-west-2: ami-5e6bce3e

...both of these have the same result.

Relevant links used:

Update

Using the following link I was able to create my own Dockerfile based off the server base and installing IIS and this seems to work fine.

custom Dockerfile


Solution

  • This is not an issue with AWS AMI's, it was due to the way the Microsoft IIS Dockerfile was written / being new to Docker.

    Link to Microsoft's IIS DockerFile

    The last line (line 7):

    ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]
    

    Difference between CMD and ENTRYPOINT

    So since this Dockerfile uses ENTRYPOINT, to launch an interactive powershell session, use the following command:

    docker run --entrypoint powershell -it -p 80:80 microsoft/iis
    

    Note that it seems that the "--entrypoint" flag needs to be after run, as this won't work:

    docker run -it -p 80:80 microsoft/iis --entrypoint powershell
    

    Here is another reference link regarding ENTRYPOINT and CMD differences