The docker run command is the primary way to create and start a new container from an image. For example, docker run -it ubuntu bash launches an Ubuntu container with an interactive terminal. By default, docker run attaches to the container's foreground, but adding the -d flag runs the container in detached mode in the background and prints the container ID instead. Many other flags control networking, environment variables, mounted volumes, and resource limits, making docker run both the simplest and the richest command in the toolkit.
To see what is currently running, docker ps lists active containers, while docker ps -a also includes containers that have stopped. The output includes useful information such as container IDs, the image used, status, port mappings, and names. To manage lifecycle, docker stop container_id sends a graceful SIGTERM signal, whereas docker kill forces immediate termination with SIGKILL. Once a container is stopped, it can be deleted with docker rm container_id, or you can clean up many at once with docker container prune.
Often you need to interact with a container that is already running. The docker exec command runs an additional process inside an existing container; the common pattern docker exec -it container_id /bin/bash opens an interactive shell so you can investigate or fix problems without restarting the service. Combined with docker ps, docker stop, docker rm, and docker exec, these commands form the day-to-day toolkit for working with containers by hand.