Docker Cheatsheet

Purging All Unused or Dangling Images, Containers, Volumes, and Networks

Docker provides a single command that will 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:

docker system prune -a

Remove images

All the Docker images on a system can be listed by adding -a to the docker images command. Once you're sure you want to delete them all, you can add the -q flag to pass the Image ID to docker rmi:

Remove Single Images

docker rmi images

Remove All Images

docker rmi $(docker images -a -q)

Stop and remove containers

You can review the containers on your system with docker ps. Adding the -a flag will show all containers. When you're sure you want to delete them, you can add the -q flag to supply the IDs to the docker stop and docker rm commands:

Stop All Container

docker stop $(docker ps -a -q)

Remove the currently running container

docker rm -v container

Remove All Container

docker rm $(docker ps -a -q)

Commit

Commit container with new name repository

docker commit -m="Add tensorflow" container user/repo

Publish image

docker push user/repo:latest

Connect to Docker Container

Buka shell baru di container yang sedang berjalan

docker exec -it container bash

Connect ke container yang sedang berjalan, dan melihat apa adanya tampilan di prompt

docker attach container

Source

https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes

Share on Twitter | Discuss on Twitter

Stay in touch

Like the posts you see here? Sign up to get notified about new ones.