Docker
Contents
Handy Tricks for Docker
Build New Image
Builds based of current directory
docker build .
With a name & tag
docker build -t <name>:<tag> .
# Eg
docker build -t awesomeimage:1.0 .
List all images
docker image ls
# OR
docker ima
Delete an image
First retrieve the image ID using the ls command.
docker image rm <id>
If the image is used by multiple containers & you’re sure you want to delete it, you can run:
docker image rm -f <id>
To delete all unused & “dangling” images
#lists all images that are dangling and has no pointer to it
docker images --filter dangling=true
#Removes all those images.
docker rmi -f `docker images --filter dangling=true -q`
Run Image
docker run <image name>
To explore the built environment
docker run -it <image name> sh
View Running Images
docker ps
Stop Running Image
First get the container ID using the ps command
docker kill <container ID>