Docker Cookbook: Difference between revisions
Jump to navigation
Jump to search
| Line 24: | Line 24: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ docker rmi [IMAGE_NAME] | $ docker rmi [IMAGE_NAME] | ||
</syntaxhighlight> | |||
Clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container): | |||
<syntaxhighlight lang="bash"> | |||
$ docker system prune | |||
</syntaxhighlight> | |||
To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command: <ref>[https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes How To Remove Docker Images, Containers, and Volumes]- DigitalOcean</ref> | |||
<syntaxhighlight lang="bash"> | |||
$ docker system prune -a | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 23:07, 8 October 2018
View all running containers
$ docker ps
Removing containers
$ docker stop [CONTAINER_ID] $ docker rm [CONTAINER_ID]
Managing images
List all images: [1]
$ docker images -a
Remove an image:
$ docker rmi [IMAGE_NAME]
Clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):
$ docker system prune
To additionally remove any stopped containers and all unused images (not just dangling images), add the -a flag to the command: [2]
$ docker system prune -a
Viewing files in a container
$ docker exec -t -i mycontainer /bin/bash
Exit the connection and return to the regular local filesystem command prompt with exit.
See also
- ↑ How To Remove Docker Images, Containers and Volumes - Digital Ocean
- ↑ How To Remove Docker Images, Containers, and Volumes- DigitalOcean