6 Docker Containers
A focused guide to Docker Containers, connecting core concepts with practical Docker and container operations.
Docker containers are runnable instances of an image — a process (or set of processes) running in its own isolated namespace and cgroup-constrained environment, using the image's filesystem as its starting point, with any changes made during the container's life stored in its own separate, writable layer.
Creating and Running a Container
A container is created and started from an existing image, typically with a single command.
docker run -d --name myapp-container myapp:1.0
This creates a new container from the myapp:1.0 image and starts its main process, running detached in the background.
A Container's Relationship to Its Image
Multiple containers can be created from the same image, each running independently, with its own isolated process and its own writable layer, despite all sharing the same underlying, immutable image layers.
docker run -d --name container-a myapp:1.0
docker run -d --name container-b myapp:1.0
Both containers run independently and can be modified, stopped, or removed individually without affecting the other or the shared underlying image.
Inspecting a Running Container
A container's current state, configuration, and resource usage can all be inspected directly.
docker ps
docker inspect myapp-container
docker stats myapp-container
Stopping and Removing a Container
A container can be stopped (allowing its process to terminate) and later removed (deleting its writable layer and the resources Docker used to track it).
docker stop myapp-container
docker rm myapp-container
Why Understanding Containers Matters
A clear distinction between an image (a static, reusable template) and a container (a running, stateful instance of that template) is foundational to using Docker effectively, since nearly every operational concept — networking, volumes, resource limits — applies specifically to containers, built from the underlying image but distinct from it.