Docker Command Reference
Container Lifecycle Management
- run - Create and start a new container.
- start/stop/restart - These commands are mainly used to start, stop, and restart containers.
- kill - Immediately terminate one or more running containers
- rm - Used to delete one or more stopped containers.
- pause/unpause - Pause and resume all processes in a container.
- create - Create a new container, but it will not start it.
- exec - Execute a new command inside a running container.
- rename - Rename a container.
Container operations
- ps - List Docker containers
- inspect - Get detailed information about Docker objects (containers, images, volumes, networks, etc.).
- top - Display the running processes in a specified container.
- attach - Allows users to attach to a running container and interact with it.
- events - Fetch events generated by the Docker daemon.
- logs - Retrieve and view container log output.
- wait - Allows users to wait for a container to stop and obtain its exit code.
- export - Exports a container's filesystem as a tar archive.
- port - Displays port mapping information for a container.
- stats - Displays Docker container resource usage in real time.
- update - Updates Docker container resource limits, including memory, CPU, etc.
Container root filesystem (rootfs) commands
- commit - Allows users to save the current state of a container as a new Docker image.
- cp - Used to copy files or directories between a container and the host machine.
- diff - Shows changes to a Docker container's filesystem.
Registry
- login/logout - Manage authentication between the Docker client and the Docker registry.
- pull - Pull (download) images from a Docker registry (e.g., Docker Hub) to the local machine.
- push - Push (upload) locally built Docker images to a Docker registry (such as Docker Hub or a private registry).
- search - Used to search for images in Docker Hub or other registries.
Local Image Management
- images - List local Docker images.
- rmi - Remove images that are no longer needed.
- tag - Create an alias (tag) for a local image.
- build - Build a Docker image from a Dockerfile.
- history - View the history layer information of a specified image.
- save - Save one or more Docker images to a tar archive file.
- load - Load Docker images from a tar file generated by the docker save command.
- import - Import a container snapshot from a tar file or URL to create a new Docker image.
info|version
- info - Display system-wide information about Docker, including the current number of images and containers.
- version - Display version information for the Docker client and server.
Docker Compose
- docker compose run - Start a new container and run a specific application.
- docker compose rm - Start a new container and delete a specific application.
- docker compose ps - Check the status of Docker containers from docker compose.
- docker compose build - Build the docker compose file.
- docker compose up - Run the docker compose file.
- docker compose ls - List docker compose services.
- docker compose start - Start the containers created by the docker compose file.
- docker compose restart - Restart the containers created by the docker compose file.
- docker compose down - Remove service-related containers and networks.
Network commands
docker network ls: List all networks.docker network create <network>: Create a new network.docker network rm <network>: Delete the specified network.docker network connect <network> <container>: Connect a container to a network.docker network disconnect <network> <container>: Disconnect a container from a network.
View Details:docker network command
Volume commands
docker volume ls: List all volumes.docker volume create <volume>: Create a new volume.docker volume rm <volume>: Delete the specified volume.docker volume inspect <volume>: Display detailed information about a volume.
View Details:docker volume command
other extensions