Here are some of the most commonly used Docker commands, organized for quick reference:
Image Management
docker images
: Lists all Docker images available on the host machine.docker build
: Builds an image from aDockerfile
.docker rmi
: Removes an image from the host machine.
Container Management
docker run
: Runs a Docker container. Common arguments:-d
: Run the container in the background and print the container ID.-p
: Port mapping (e.g.,-p 8080:80
).
Use docker run --help
for more options.
docker ps
: Lists all running containers.docker stop
: Stops a running container.docker start
: Starts a stopped container.docker rm
: Removes a stopped container.
Registry Operations
docker pull
: Downloads an image from the configured registry.docker push
: Uploads an image to the configured registry.
Advanced Commands
docker exec
: Runs a command inside a running container.docker network
: Manages Docker networks (e.g., creating/removing networks, connecting containers to networks).