2022-03-08 08:04:10 +00:00
|
|
|
% docker
|
2020-11-21 09:07:54 +00:00
|
|
|
|
|
|
|
# Create a volume
|
|
|
|
sudo docker volume create <name>
|
|
|
|
|
|
|
|
# List all volumes
|
|
|
|
sudo docker volume ls
|
|
|
|
|
|
|
|
# Remove volume
|
|
|
|
sudo docker volume rm <volume>
|
|
|
|
|
|
|
|
$ volume: sudo docker volume ls --format "{{.Name}}" | awk '{print $1}'
|
|
|
|
|
|
|
|
# Create new network
|
|
|
|
docker network create <name>
|
|
|
|
|
|
|
|
# List the networks
|
|
|
|
sudo docker network ls
|
|
|
|
|
2022-03-08 08:04:10 +00:00
|
|
|
# Remove volume
|
|
|
|
sudo docker volume rm <network>
|
|
|
|
|
|
|
|
$ network: sudo docker network ls --format "{{.Name}}" | awk '{print $1}'
|
2020-11-21 09:07:54 +00:00
|
|
|
|
|
|
|
# List the running containers
|
|
|
|
sudo docker ps
|
|
|
|
|
|
|
|
# Stop a running container through SIGTERM
|
2022-03-08 08:04:10 +00:00
|
|
|
sudo docker stop <container>
|
2020-11-21 09:07:54 +00:00
|
|
|
|
|
|
|
# Stop a running container through SIGKILL
|
2022-03-08 08:04:10 +00:00
|
|
|
sudo docker kill <container>
|
|
|
|
|
|
|
|
# Execute bash on a running container
|
|
|
|
sudo docker exec -it <container> bash
|
|
|
|
|
|
|
|
# Execute a command on a running container
|
|
|
|
sudo docker exec -it <container> sh -c '<command>'
|
2020-11-21 09:07:54 +00:00
|
|
|
|
|
|
|
# Print the last lines of a container's logs
|
2022-03-08 08:04:10 +00:00
|
|
|
sudo docker logs --tail 100 <container> | less
|
2020-11-21 09:07:54 +00:00
|
|
|
|
|
|
|
# Print the last lines of a container's logs and following its logs
|
2022-03-08 08:04:10 +00:00
|
|
|
sudo docker logs --tail 100 <container> -f
|
2020-11-21 09:07:54 +00:00
|
|
|
|
2022-03-08 08:04:10 +00:00
|
|
|
$ container: sudo docker container ls --format "{{.Names}}" | awk '{print $1}'
|