Docker

Contents

Handy Tricks for Docker

Builds based of current directory

docker build .

With a name & tag

docker build -t <name>:<tag> .

# Eg
docker build -t awesomeimage:1.0 .
docker image ls

# OR
docker ima

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` 
docker run <image name>

To explore the built environment

docker run -it <image name> sh
docker ps

First get the container ID using the ps command

docker kill <container ID>