I am running boot2docker on my Windows 7. Inside the VM image I am trying to stop all of the Docker images, however I get an error:
docker@boot2docker:~$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
svendowideit/samba latest ce8e4e03282a 8 days ago 252 MB
hello-world latest e45a5af57b00 13 days ago 910 B
busybox latest 4986bf8c1536 13 days ago 2.433 MB
docker@boot2docker:~$ docker stop e45a5af57b00
Error response from daemon: No such container: e45a5af57b00
FATA[0000] Error: failed to stop one or more containers
docker@boot2docker:~$ docker kill e45a5af57b00
Error response from daemon: No such container: e45a5af57b00
FATA[0000] Error: failed to kill one or more containers
To stop all docker containers:
$ docker stop $(docker ps -a -q)
Then to remove all docker containers:
$ docker rm $(docker ps -a -q)
To remove all docker images:
$ docker rmi $(docker images -q)
You are looking at images and trying to stop container. They are not the same. docker ps will give you running containers, docker ps -a will give you all containers.
Images are just images of filesystem which used by docker run command. docker run creates container which could be stopped or removed (docker rm) but you rarely need to remove image (docker rmi).
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest 5506de2b643b 11 weeks ago 199.3 MB
$ docker run ubuntu
$ docker run ubuntu
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
037b45371358 ubuntu:latest "bash" 2 seconds ago Exited (0) 2 seconds ago goofy_yalow
7a1f93ed42b3 ubuntu:latest "bash" 4 seconds ago Exited (0) 3 seconds ago admiring_yalow
As you see ids are different - these containers already exited - so they could not be stopped, they could be inspected, removed, restarted. If you don't need container when process there is finished - you could use --rm option:
docker run --rm ubuntu
then container will be removed automatically when it is stopped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With