π Introduction
Docker has transformed the way we develop, ship, and deploy applications by providing consistent environments across development, testing, and production. Whether you're just starting out or need a refresher, this Docker CLI cheatsheet covers the most essential commands every developer should know.
π§ Getting Started
π¦ Build a Docker Image
docker build -t <image_name> .
π₯ Build Without Cache
docker build -t <image_name> . --no-cache
π List Local Images
docker images
π§Ή Remove an Image
docker rmi <image_name>
π§Ό Prune Unused Images
docker image prune
π Docker Hub & Authentication
π Login to Docker Hub
docker login -u <username>
π Push Image to Docker Hub
docker push <username>/<image_name>
π Search for Images
docker search <image_name>
π₯ Pull an Image
docker pull <image_name>
π§ͺ Working with Containers
π Run a Container
docker run --name <container_name> <image_name>
π Run with Port Mapping
docker run -p <host_port>:<container_port> <image_name>
πΆ Run in Background (Detached Mode)
docker run -d <image_name>
βΆοΈ Start / βΉ Stop Container
docker start <container_name>
docker stop <container_name>
π Remove Stopped Container
docker rm <container_name>
π₯ Access Running Container
docker exec -it <container_name> sh
π Logs, Stats & Monitoring
π View Logs
docker logs -f <container_name>
π Inspect Container Details
docker inspect <container_name>
π List Running Containers
docker ps
π List All Containers
docker ps -a
π Monitor Usage Stats
docker container stats
βοΈ Miscellaneous & System Info
π³ Start Docker Daemon
docker -d
π Get Help on Any Command
docker --help
βΉοΈ Show Docker System Info
docker info
Top comments (0)