Docker
see also: Docker Compose / Docker Swarm
file locations
/var/lib/docker/volumes | Volumes |
Tools
- ctop – top like tool for container metrics.
Useful containers
Automated Nginx Proxy | jwilder/nginx-proxy |
---|---|
Automated Nginx Letsencrypt Companion | jrcs/letsencrypt-nginx-proxy-companion |
Nextcloud | nextcloud |
TCP Proxy | tecnativa/docker-tcp-proxy |
UDP Proxy | instantlinux/udp-nginx-proxy |
PostgreSQL | postgres |
useful commands
Start interactive shell in container
docker exec -ti container sh
List stopped containers
docker ps --filter "status=exited"
Get command used to start a Docker container
docker inspect -f '{{json .Config}}' CONTAINERID | jq '.Env'
Get IP of a container
docker inspect --format '{{ .NetworkSettings.IPAddress }}' CONTAINERID
Storage
Free up space
docker system prune -a WARNING! This will remove: - all stopped containers - all volumes not used by at least one container - all images without at least one container associated to them Are you sure you want to continue? [y/N] y
Identify space wasters in overlay2 directory
prune images
# delete all volumes not in use or dangling docker volume rm $(docker volume ls -qf dangling=true) # same docker system prune --all --volumes --force
show all mounted directories
docker inspect -f '{{ range .Mounts }}{{ .Source }}:{{ .Destination }} {{ end }}' $(docker-compose ps -q)
Backup / restore
- Bivac - backup container volumes using Restic
MySQL DB
# Backup docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql # Restore cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
Host OS
Minimalist Docker-only/-centric
see also: The New Minimalist Operating Systems (blog.docker.com)
- Rancher
- Project Atomic
- CoreOS
- Snappy Ubuntu Core
caveats
bind mounts & SELinux
to be able to access mounts with enabled SELinux, you need to specify :z
or :Z
to the bind mount option.
See also: https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label
Troubleshooting
mysql/mariadb doesn't work after I pulled a new image
docker exec CONTAINERNAME mysql_upgrade "-uroot" "-pROOTPASSWORD"