Images
docker imagesList all images
docker build -t name:tag .Build an image from Dockerfile
Example:
docker build -t myapp:1.0 .docker build -t <image_name> . –no-cacheBuild an Image from a Dockerfile without the cache
docker pull <image>Pull an image from registry
docker rmi <image>Remove an image
docker tag <source> <target>Tag an image
docker image pruneRemove all unused images
Containers
docker psList running containers
docker ps -aList all containers (including stopped)
docker run -d -p host:container imageRun container in detached mode with port mapping
Example:
docker run -d -p 8080:80 nginxdocker run -it --rm -v /path/on/host:/path/in/container <image> shRun container in interactive mode with volume mount. Remove container once the container is stopped
docker exec -it <container> /bin/shExecutes an interactive shell inside an already running container
docker stop <container>Stop a running container
docker start <container>Start a stopped container
docker rm <container>Remove a container
docker exec -it <container> bashExecute interactive bash in container
docker logs <container>View container logs
docker logs -f <container>Follow container logs
docker inspect <container>To inspect a running <container_name> (or <container_id>)
docker container statsView resource usage stats
docker port <container>Show port binding to host
System
docker system prune -aRemove all unused containers, networks, images
docker system dfShow docker disk usage
docker infoDisplay system-wide information