A list of commands for Docker.
- General
- Image management
- Container information
- Container creation
- Container management
- Saving containers
List all available commands:
docker
View the options available to a specific command:
docker <subcommand> --help
View system-wide information about Docker;
docker info
Clean up any resources that are dangling (not associated with a container) in
addition to any stopped containers and all unused images (-a
):
docker system prune -a
Search for an image:
docker search <image>
Download an image:
docker pull <image>
List all downloaded images:
docker images
Remove an image:
docker rmi <image>
Get detailed information about a container:
docker inspect <container_id>
Provide the statistics of a running container:
docker stats <container_id>
See the top processes within a container:
docker top <container_id>
Run an image:
docker run <image>
Run an image (Ubuntu here) in a container named myname with access to an
interactive (-i
) shell (-t
) that removes itself when stopped (--rm
):
docker run -it --rm --name myname ubuntu
Run an image and map a local directory to a container directory:
docker run -v source/:dest/ <image>
View all (-a
) containers (active and inactive) with their size (-s
):
docker ps -as
Start a stopped container:
docker start <container_id>
Stop a running container:
docker stop <container_id>
Remove a container:
docker rm <container_id>
Attach to a running container:
docker attach <container_id>
Detach from an interactive shell (-it
) inside a container:
CTRL-p CTRL-q
Commit changes to a new Docker image:
docker commit -m "Commit message" -a "Author name" container_id repository/new_image_name