1

I am trying to run some tests of Docker Containers on Server 2016. I have installed the Container feature and the latest Docker Engine and CLI. I Have downloaded several Docker Images, I have used them to launch Docker Containers and customised those containers, committed the changes and used them to create custom Docker Images.

So far so good:

I have used the following command to create a container from one of Microsoft Docker images:

docker run -d --name miis -p 80:80 microsoft/iis ping -t localhost

The container (miis) runs fine, I can connect to it:

docker exec -i miis cmd

the problem starts when I stop the container and try to restart it. I use the following to stop and the start the container:

docker stop miis

docker start miis

when I then try and to get a list of the running containers using: docker ps, my container isn't listed. When I get a list of all container using: docker ps -a my container is listed with a status of Exited.

As I understand the problem the container is starting, running the job it is supposed to run then immediately exiting.

My question is how can I start my new containers created from Microsoft or custom images and keep them running? stooping them from immediately going to an Exited state.

I thought the ping -t localhost would do this, but this only seem to work for a while and it prevents me from gaining access to the container CMD prompt.

4
  • What's the output of "docker logs miis"?
    – EEAA
    Jul 16, 2017 at 18:18
  • 1
    Additionally, why bother with starting and stopping the containers? Just nuke it and start a new one.
    – EEAA
    Jul 16, 2017 at 18:20
  • So I might be thinking of this a little bit wrong. instead of thinking of containers as things that I need to keep and stop and restart like VMs I should see them as disposable. It is the Docker Images that are the important component that I use again and again to create containers as needed across my Docker hosts. Jul 16, 2017 at 18:28
  • 1
    Yep, absolutely. Containers should be seen as ephemeral. Remember the cattle/pets analogy. As long as you take care to never keep any application state in the container, just start, destroy, restart.
    – EEAA
    Jul 16, 2017 at 19:11

1 Answer 1

0

Docker containers will run as long as they are intended or until running into a devastating error.

I would check to make sure you don't have any commands in your Docker image that are terminating (IE giving off an exit code).

If you are still having issues, check the docker log to see why its exiting. Usually an exit code of zero means it finished and a clean exit code was issued. Otherwise it should give you more information of what is causing the container to close (missing dependences or IIS is crashing.

On Windows, the logs are stored into the event viewer, using this command:

Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5)

Here is a reference for looking at logs:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/troubleshooting#finding-logs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .