ls [OPTIONS] |
list running containers |
ls --all|-a |
list all containers |
ls --size|-s |
list running containers sizes |
ls -q |
display container IDs of running container (q stands for quiet) |
ls --format '{{printf "%-40s" .Names}} {{.Ports}}' |
display name and ports of running containers |
start|stop|pause|unpause|restart|rm CONTAINER |
start, stop, pause, unpause, restart or remove container |
logs --tail|-n 10 CONTAINER |
show the last 10 lines of logs |
logs [OPTIONS] CONTAINER |
fetch the logs of a container |
logs --timestamps|-t CONTAINER |
show logs including timestamps |
run [OPTIONS] IMAGE [COMMAND] [ARG...] |
create a new container and run a command into it |
run --name CONTAINER nginx:1.22.0 |
create CONTAINER using nginx image tagged 1.22.0 |
run -p 8080:80 IMAGE |
maps the host port 8080 to the created container port 80 |
run --detach|-d IMAGE |
run container in background and print container ID |
run --rm -it IMAGE CMD |
create a container, run a cmd on it interactively, then delete the container |
run --net NETWORK IMAGE |
--net connects a container to NETWORK |
run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql |
create a named volume mysql-db pointing to the container directory /var/lib/mysql |
run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx |
create a bind mount between the host current directory and /usr/share/nginx/html |
run --name postgres-db -e POSTGRES_PASSWORD=password --mount type=volume,source=$HOME/docker/volumes/postgres,target=/var/lib/postgresql/data -p 2000:5432 -d postgres |
create a named volume between the host directory $HOME/docker/volumes/postgres and the container directory /var/lib/postgresql/data |
run --name postgres-db -e POSTGRES_PASSWORD=password --v $HOME/docker/volumes/postgres:/var/lib/postgresql/data -p 2000:5432 -d postgres |
create a named volume between the host directory $HOME/docker/volumes/postgres and the container directory /var/lib/postgresql/data |
run -d --name postgres-db -e POSTGRES_PASSWORD=password --mount type=bind,source="$pwd",target=/var/lib/postgresql/data -p 2000:5432 -d postgres |
create a bind mount between the host current directory and the /var/lib/postgresql/ directory in the container. |
run --health-cmd="curl -f localhost:9200/_cluster/health || false" --health-interval=5s --health-retries=3 --health-timeout=2s --health-start-period=15s IMAGE |
health check |
ps -a --filter volume=VOLUME |
display all containers using VOLUME |
ps --no-trunc |
prevent truncating output |
|
|
top CONTAINER [ps OPTIONS] |
display the running processes of a container |
|
|
rm --force|-f CONTAINER |
force the removal of a running container (uses SIGKILL) |
stats [OPTIONS] CONTAINER |
display a live stream of running container(s) resource usage statistics |
stats --all|-a CONTAINER |
display a live stream of ALL running container(s) resource usage statistics |
inspect --size|-s --pretty CONTAINER |
display detailed information on one or more containers with size |
update -c 4 -m 8G CONTAINER |
|
commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] |
Create a new image from a container’s changes excepts on volumes. |
commit --change "ENV DEBUG=true" CONTAINER [REPOSITORY[:TAG]] |
Apply Dockerfile instruction to the created image |
exec -it CONTAINER sh -c "test -d /some/dir && echo 'It Exists'" |
test if a folder exists in a container |
docker container inspect CONTAINER --format '{{json .NetworkSettings}}' | jq |
pretty print container's network info |
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by Boulard