Docker Cheat sheet

Docker Cheat sheet

·

2 min read

#Day 20 Task of #90DaysofDevops challenge🚀

let's start 🚗

Basic Docker Commands :

Docker pull: Pulls an image or a repository from a registry.

docker pull <image-name>

Docker push: Pushes an image or a repository to a registry.

docker push <image-name>

Docker images: Show a list of all the images on the local system.

docker images

Docker rmi: Removes one or more images.

docker rmi <image-name>

Docker build: Build and tag an image from a Docker file.

docker build [OPTIONS] PATH | URL |

docker build -t <image_name>.

Docker run: Runs a command in a new container. assign it a name and map a port. start the container in the background with the -d option.

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

docker run -d --name <container-name> -p 80:80 <image-name>

Docker start: Starts one or more stopped containers.

docker start <container-name>

Docker stop: Stops one or more running containers.

docker stop <container-name>

Docker exec: Runs a command in a running container and goes inside a container.

docker exec -it <container-name or ID> bash

Docker rm: Removes one or more containers.

docker rm <container-name or ID>

Docker ps: It shows a list of all running containers.

docker ps

Docker ps -a: It shows a list of all containers.

docker ps -a

Docker logs: Fetches the logs of a container.

docker logs <container-name or ID>

Docker inspects: Returns low-level information on a container or image.

docker inspect <container-name or ID>

Docker Port: Show mapped ports of the container.

docker port <container-name or ID>

Docker Top: Lists the processes running inside the container.

docker top <container-name or ID>

Docker Volume :

Docker volume create: Create a volume

docker volume create <volume-name>

Docker volume ls: List volumes

docker volume ls

Docker volume inspect: Display detailed information on one or more volumes

docker volume inspect <volume-name>

Docker volume rm: Remove one or more volumes

docker volume rm <volume-name>

Docker volume prune: Remove all unused volumes

docker volume prune

Docker Compose :

Docker-compose up: Create and start containers

docker-compose up

Docker-compose ps: List containers

docker-compose ps

Docker-compose down: Stop and remove containers, networks, images, and volumes

docker-compose down

Docker-compose logs: Show logs

docker-compose logs <service>

Thank you very much for giving your valuable time for reading this article !!☺😊

Arijit Manna

Â