✦ For everyone, free.

Practical knowledge for real and everyday life

Home

6.1.2 Container Execution

A focused guide to Container Execution, connecting core concepts with practical Docker and container operations.

Container execution is the phase of a container's lifecycle where its configured main process actually begins running, transitioning the container from a created (but inert) state into an active, running state where it consumes resources and performs whatever work its main process is designed to do.

Starting Execution

Execution begins either as part of docker run (which combines creation and starting) or explicitly through docker start for an already-created container.

docker run -d myapp:1.0
docker create --name myapp myapp:1.0
docker start myapp

Both approaches eventually reach the same execution phase, differing only in whether creation and starting happen as one combined step or two explicit ones.

What Determines What Actually Executes

The image's ENTRYPOINT and CMD instructions, possibly overridden by run-time arguments, together determine exactly what process begins running once execution starts.

docker run myapp:1.0
docker run myapp:1.0 --verbose

The second invocation appends an additional argument, which — depending on the image's ENTRYPOINT configuration — may be passed along to the executing process.

Observing an Executing Container

A container's running status, resource consumption, and output can all be observed once execution has actually begun.

docker ps
docker logs myapp
docker stats myapp
When Execution Ends

Execution ends when the main process exits, either on its own (the application completes its work or crashes) or because it was explicitly stopped.

docker stop myapp
Why Understanding Container Execution Matters

Recognizing execution as the specific phase where a container's actual work happens — distinct from creation, which merely prepares the container — clarifies what is actually happening operationally when a container transitions from existing to actively running, and helps in diagnosing situations where a container exists but isn't actually doing anything.

Content in this section