Before using the docker stop command can be used to stop a container, you will probably want to use the docker ps command to determine if the container is running. In this example, the bar container has been running for 12 hours.
~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d7bf9e534d50 foo "/docker-entrypoint.…" 12 hours ago Up 12 hours 80/tcp bar
A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
The docker stop command with the container name can be used.
docker stop bar
Or with the container ID.
docker stop d7bf9e534d50
Did you find this article helpful?
If so, consider buying me a coffee over at