Docker Commands

How to show list of all Docker Images

docker images -a

How to view list of all Running Docker Containers

docker ps

Howt to view list of all Docker Containers

docker ps -a

How to start Docker Container

docker start <container name>

How to stop running Docker Container

docker stop <container name>

How to kill all Running Containers

docker kill $(docker ps -q)

How to view logs of Running Docker Container

docker logs <container name>

How to delete all Stopped Docker Containers

docker rm $(docker ps -a -q)
Use -f option to nuke the running containers too.

How to remove a Docker Image

docker rmi <image name>

How to delete all Docker Images

docker rmi $(docker images -q)

How to delete All Untagged/dangling Docker Images

docker rmi $(docker images -q -f dangling=true)

How to delete All Images

docker rmi $(docker images -q)

How to remove Dangling Volumes

docker volume rm -f $(docker volume ls -f dangling=true -q)

How to run Docker Image

docker run <image name>

How to see the Console Output of Docker Container

docker logs <container name>

How to build a docker image

docker build -t <tag name>

How to stop a docker container

docker kill <container name>
or
docker stop <container name>

How to list all docker images on your system

docker images

How to map a host port to a Container Port

-p <host port>: <container port>
Example:
docker run -p 8080:8080 <image name>

How to remove stopped Docker Container

docker rm <container name>

How to remove a Docker Image from your System

docker rmi <image name>

Keep Learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *