Quick Docker commands list

Quick Docker commands list

docker ps Show running containers

docker ps -a Show all containers

docker images Show images

docker rm <container_name> Remove(delete) container

docker rmi <image_name> Remove(delete) image

docker stop <container_name> Stop container

docker build -t my-app Build a docker image in local environment named my-app

docker run -p 4000:80 -d my-app Run container my-app. When I go to port 4000 in my browser, I will reach to port 80 in docker environment. Run this container in detached mode.

docker logs <container_id> Show terminal output in running container

docker-compose up -d Run docker compose file and leave the container in detached mode

docker-compose --verbose up Start a container with verbose settings so that we know what’s going wrong etc.

docker kill $(docker ps -aq) Kill all running containers

docker rm $(docker ps -aq) Remove all containers

docker exec -ti <container_name> /bin/bash Open a bash terminal in a container

docker exec -ti <container-name> sh Open a shell terminal in the container


Leave a Reply

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