docker
Reference manpage: man docker
Run temporary container
As you exit the main process the container will stop and all data be erased.
This is really usefull if you want a quick dive into a different os.
docker run --rm -it nixos/nix bash
List IP address of containers
docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }} {{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' | sed 's#^/##';
Output:
ecorp-controller-1 192.168.69.3 ecorp-gitlab-1 192.168.69.2 ecorp-core-gitlab-runner-1 192.168.69.4 ecorp-dns-1 192.168.69.9 ecorp-dc-1 192.168.69.10 affine_server 172.19.0.3 affine_postgres 172.19.0.4 affine_redis 172.19.0.2 xrdp-sandbox-xrdp-dev-sandbox-1 172.18.0.2 transmission-transmission-1 172.23.0.2 docker-model-runner 172.17.0.2 kind-control-plane 172.26.0.2
Transfer image on ssh
There is a way to transfer images between instances without hosting a repository
Copy from remote
ssh $REMOTE docker image save $IMG | docker image import - $IMG
Copy to remote
docker image save $IMG | ssh $REMOTE docker image import - $IMG
Get disk usage
docker system df
Output:
TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 50 10 24.84GB 14.15GB (56%) Containers 10 10 1.791GB 0B (0%) Local Volumes 3 3 121.6MB 0B (0%) Build Cache 224 0 13.67GB 0B
Clean up space
Release all danglink container, network, image, etc (but not volumes) and retrieve disk space after it.
System prune does not delete unused volumes, it have to be done in extra step.
docker system prune -af docker volume prune -af