Thuta Learning
BasicDevOps & Toolsintermediate

stop, start, rm

Relax. We'll talk through this in plain words — no textbook voice.

Once a container is running, you'll need to stop, start, restart, or remove it at some point. In local development, leaving containers around without cleaning them up can lead to port conflicts and disk space filling up, so it pays to know how to manage them.

dockerfile
# Stop a running container
docker stop web-demo

# Start an existing stopped container
docker start web-demo

# Restart a container
docker restart web-demo

# Remove a stopped container
docker rm web-demo

# Force remove a running container when needed
docker rm -f web-demo

stop stops a running container. start starts an existing stopped container back up. rm deletes a container. If you want to delete a running container, you should generally stop it first.

You should see
If the command succeeds, the terminal will print back the container name or container ID.

Info

docker rm deletes a container. If you want to delete an image, use docker rmi instead.

Easy traps

  • Deleting a container with docker rm can wipe out any data stored inside it. If the data matters, use a volume instead.
stop, start, rm | Thuta Learning