Cheatography
https://cheatography.com
Basic commands for Docker, translated from:
https://cheatography.com/azertytr/cheat-sheets/docker/ & https://cheatography.com/hallo/cheat-sheets/docker-komendy/
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic Docker Commands
|
List of started containers |
|
List of all containers |
|
Get configuration from docker |
|
Get docker version |
docker build -t
<image>:<tag> .
|
Builds a Docker image from a "Dockerfile" or a container. |
docker login
<repository>
|
Connect to a remote repository |
docker push
<image_name>:<tag>
|
Push the image to the remote repository |
docker pull
<image_name>:<tag>
|
Pull image from remote repository |
Container Orders
docker inspect <Container>
|
Controls a container |
docker stats <Container>
|
Displays the container's live data stream |
docker logs <Container>
|
Fetch container logs |
docker run <Container>
|
Run the container |
docker kill <Container>
|
Kill a running container |
docker start <Container>
|
Start the container |
|
Stop a running container |
docker restart <Container>
|
Restart the container |
|
Delete the container |
docker port <Container>
|
List container port mapping |
docker break <Container>
|
Suspend all container processes |
docker unpause <Container>
|
Unsuspend all container processes |
<Container> can be replaced by the
ID or the NAME of the container.
Network Commands
|
List of networks |
docker network inspect <Network>
|
Check network information |
docker network create <Network>
|
Create a network |
docker network rm <Network>
|
Delete a network |
docker network connect <Network> <Container>
|
Connects a container to the network |
docker network connect --ip <IP> <Network> <Container>
|
Specifies the container interface IP address |
docker network disconnect <Network_Name> <Container>
|
Disconnects the container from the network |
<Network> can be replaced by the network ID or NAME.
Miscellaneous Commands
docker cp <Container>:<source_path> <dest_path>
|
Copy from container to host |
docker cp <source_path> <Container>:<dest_path>
|
Copy from host to container |
docker exec -ti <Container> <Entrypoint>
|
Runs the terminal from a live container |
Dockerfile
|
Specifies the parent image |
COPY <source_path> <destination_path>
|
Copies regular files and directories. |
ADD <source_path> <destination_path>
|
Same as COPY
, but unpacks tarballs and accepts URLs |
CMD [<command> <parameters>]
|
Specifies the command to execute when initializing the container with this image |
ENTRYPOINT [<command> <parameters>]
|
Similar to CMD
but cannot be overwritten, it will always be executed and the container will run as an executable |
|
Adds metadata to the Docker image |
|
Sets environment variables for the container |
EXPOSE <port_number>/<Âprotocol_type>
|
Sets the ports that will be exposed by the container |
|
Runs commands in the container; usually used to install packages |
WORKDIR <directory_path>
|
Specifies the working directory. Once the container is executed, this is the directory we will end up in when we access the container. |
|
|
Option Keywords
|
Port mapping between host and container |
|
Publish all ports |
|
Exposes the port of the container |
|
Runs in the background |
|
Sets environment variables |
|
Mount files or directories |
|
Provides access to a command prompt in a running container |
|
|
Execute a new command in a container |
|
Copy data between container and host or vice versa |
These option keywords can be added to most docker commands.
Image Commands
|
Lists locally available images |
|
Run the image |
docker create
<image>:<Tag>
|
Create an image |
|
Delete the image |
|
Save images to a tarball |
|
Docker image search |
|
Get a docker image |
docker build -t
<image>:<tag> <run_directory> -f <dockerfile>
|
Build an image from a "dockerfile" |
|
Remove all unused docker images |
Volume Commands
|
List the volumes |
docker volume inspect <Volume>
|
Control the volume |
docker volume create <Volume>
|
Create a volume |
docker volume rm <Volume>
|
Delete a volume |
|
Delete unused volumes |
<Volume> can be replaced by volume ID or NAME.
Repair & Diagnostics
|
Show disk space used by docker |
|
Displays Docker system information |
docker diff <container>
|
Shows all files that have been modified since startup |
docker top <container>
|
Show "top" command output of processes running in a container |
|
Show output of "top" command from all Docker containers |
docker logs <container>
|
Show container logs |
docker top <container>
|
Show the processes in container |
docker diff <container>
|
Show all modified files in the container |
|