Essential Docker Command Reference
Build a image from Dockerfile:
docker build -t app-image:latest .
Export image to archive:
docker save -o backup.tar app-image:latest
Import image from archive:
docker load -i backup.tar
Run container with parameters:
docker run -d \\
--name web-service \\
-p 8080:80 \\
-v /host/logs:/container/logs \\
--net bridge \\
--platform linux/amd64 \\
app-image:latest
Network Configuration
Network modes:
bridge: Isolated network stack (default)host: Shares host's network namespacenone: Disables networking
Check image platform:
docker inspect --format '{{.Os}}/{{.Architecture}}' app-image:latest
Buildx Multi-Platform Tool
Initialize builder:
docker buildx create --name multiarch-builder
docker buildx use multiarch-builder
docker buildx inspect --bootstrap
Build and push multi-arch image:
docker buildx build \\
-t registry/app-image:multi \\
--platform linux/amd64,linux/arm64 \\
--push .
Core Operations
docker pull [repo/image]: Retrieve imagedocker push [repo/image]: Upload imagedocker images: List local imagesdocker rmi [image]: Delete imagedocker run [options] [image]: Create containerdocker stop [container]: Halt containerdocker start [container]: Resume containerdocker restart [container]: Recycle containerdocker rm [container]: Remove containerdocker ps: Show active containersdocker logs [container]: View output streamdocker exec -it [container] sh: Access shelldocker inspect [target]: Show metadata
Autostart configuration:
systemctl enable docker
docker update --restart unless-stopped [container]
Volume Commands
docker volume create [name]: Provision storagedocker volume ls: Enumerate volumesdocker volume rm [volume]: Delete volumedocker volume inspect [volume]: Show propertiesdocker volume prune: Purge unused volumes
Network Commands
docker network create [name]: Establish networkdocker network ls: List networksdocker network rm [network]: Remove networkdocker network prune: Clean unused networksdocker network connect [net] [container]: Attach containerdocker network disconnect [net] [container]: Detach containerdocker network inspect [network]: Show topology
Network example:
docker network create app-net
docker network connect app-net db-container --alias sql-db
docker network connect app-net api-container
Containers in custom networks communicate via aliases or names.