Docker¶
Some additional docker commands, which might be useful. For more detailed information search the docker website https://docs.docker.com/.
Which version of docker is being used?
[ebreitmoser@awb-webapp01 how_toy]$ docker -v
Docker version 1.13.1, build 0be3e21/1.13.1
Remove all stopped containers (beware that will stop all images for all users belonging to the docker group!):
docker container prune
See here for further information.
Otherwise beware that they can take up a lot of disk space. To check the total disk space:
df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.8G 0 7.8G 0% /dev
tmpfs 1.6G 1.9M 1.6G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29G 20G 7.3G 74% /
...
So in this case we have a total of 29GB available of which 74% are already used.
Display information regarding the amount of disk space used by the docker daemon (see here).
[ebreitmoser@awb-webapp01 how_toy]$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 20 0 6.42 GB 6.42 GB (100%)
Containers 0 0 0 B 0 B
Local Volumes 0 0 0 B 0 B
The RECLAIMABLE amount of disk space is the total size consumed by unused images. To remove
- all stopped containers
- all volumes not used by at least one container
- all networks not used by at least one container
- all dangling images
Run (that's less than all unused images! But you do NOT want to delete all images)
docker system prune
Remove one or more docker images.¶
First list them all, then delete the ones you want to by using their Image ID (see https://docs.docker.com/engine/reference/commandline/rmi/):
[ebreitmoser@awb-webapp01 how_toy]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
how_toy latest 88aa985b958c 35 minutes ago 1.02 GB
<none> <none> 44e1665e9b8f 13 hours ago 1.02 GB
<none> <none> 3863d1b46f5d 14 hours ago 580 MB
[ebreitmoser@awb-webapp01 how_toy]$ docker image rmi -f 44e1665e9b8f 3863d1b46f5d
You see that the docker image typically tale ~1GB of space.
Runtime metrics¶
See https://docs.docker.com/config/containers/runmetrics/. Look which containers are currently running. Then choose one
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d1644205de1c stm_industry "R -e 'rmarkdown::ru..." 18 minutes ago Up 18 minutes 0.0.0.0:20000->3838/tcp jovial_goldwasser
docker stats d1644205de1c
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
d1644205de1c jovial_goldwasser 2.86% 221.9MiB / 15.63GiB 1.39% 353kB / 986kB 0B / 1.06MB 4