Docker CLI and Dockerfile Configuration Cheat Sheet
This quick reference guide summarizes high-frequency Docker CLI commands and Dockerfile directives.
1. High-Frequency CLI Operations
| Command | Action | Key Options |
docker run | Create and start a container | -d (detached), -p 80:80 (ports), -v (volumes) |
docker ps | List active containers | -a (show stopped containers too) |
docker logs | Print container stdout logs | -f (follow logs in real-time) |
docker exec | Execute commands inside container | -it (interactive terminal console) |
docker rm | Delete stopped containers | -f (force stop and delete) |
docker rmi | Delete local images | docker image prune (remove unused) |
2. Dockerfile Directives Reference
FROM: Set the base parent image.WORKDIR: Set the default working directory path inside the container filesystem.COPY: Copy files from the host machine into the container.RUN: Execute build commands in a new layer (used to install packages).ENV: Set persistent environment variables.EXPOSE: Document target listener port bindings.CMD: Set default container launch execution command parameters.ENTRYPOINT: Set target container main executor binary.
3. Storage and Networks CLI
# Network Management
docker network create net_name
docker network ls
docker network inspect net_name
# Volume Management
docker volume create vol_name
docker volume ls
docker volume rm vol_namePublished on Last updated: