Running a container from an image
The docker container run
command creates a container from an image and starts the application inside the container. It's actually equivalent to running two separate commands, docker container create
and docker container start
, which shows that containers can have different states. You can create a container without starting it, and you can pause, stop, and restart running containers. Containers can be in different states, and you can use them in different ways.
Doing one thing with a task container
The dockeronwindows/ch02-powershell-env
image is an example of a packaged application that is meant to run in a container and perform a single task. The image is based on Microsoft Nano Server and is set up to run a simple PowerShell script when it starts, printing details about the current environment. Let's see what happens when I run a container directly from the image:
> docker container run dockeronwindows/ch02-powershell-env Name ...