On Ubuntu 14.04 (Trusty Tahr) I'm looking for a way to stop a running container and the only information I have is the image name that was used in the Docker run command.
Is there a command to find all the matching running containers that match that image name and stop them?
This code will stop all containers with the image centos:6. I couldn't find an easier solution for that.
Or even shorter:
I made a
/usr/local/bin/docker.stop
that takes in the image name (assumes you only have one running).You can use the
ps
command to take a look at the running containers:From there you should see the name of your container along with the container ID that you're looking for. Here's more information about
docker ps
.The previous answers did not work for me, but this did:
Two ways to stop running a container:
You can get running containers using the following command:
Following links for more information:
You could start the container setting a container name:
The same image could be used to spin up multiple containers, so this is a good way to start a container. Then you could use this container-name to stop, attach... the container: