Table of Contents

Docker

https://github.com/docker/labs/tree/master/networking/concepts https://sysdig.com/blog/dockerfile-best-practices/
dns https://kerneltalks.com/networking/how-docker-container-dns-works/
https://labs.play-with-docker.com/

docker -D info
docker compose --ansi=never up --quiet-pull

Docker.goodPackages

Docker.scout

Docker.dedockify

Docker.Learning

Docker.commands

# docker find by name
docker ps -a --format "{{.ID}} {{.Names}}" --filter name=UismvProd_Db
 
# docker find thin r/w layer aufs by container id - ``docker ps`` 
cat /var/lib/docker/image/aufs/layerdb/mounts/<CONTAINERID>*/mount-id
<ID>
# real files in -> /var/lib/docker/aufs/diff/<ID>    <ID>-init - entry point  of container aufs start
 
# find container by name of catalog AUFS DIFF
grep 09c1f3c8c5adfb9241d477a61b5b04fd4cde07959dbee5ad385c4ef9c5e9d71d /var/lib/docker/image/aufs/layerdb/mounts/*/mount-id
<RESULT>
# this give id in path -> /var/lib/docker/aufs/diff/<RESULT>/etc/freeradius/
 
 
# inspecting docker with jq - mounts
docker inspect   d20d22ecad80 |  jq '.. | objects | with_entries(select(.key | contains("Mounts"))) | select(. != {})'
# inspect restart
docker inspect php4-fpm | jq '.[0] | .. | .RestartPolicy? // empty'
 
#Packages for container
apt install net-tools # - {netstat, ifconfig, iwconfig, route, iptunnel, arp}
apt install iproute2 # - {ss, ip, iw, ip r, ip tunnel, ip n}
apt install procps # - {ps,top}
apt install iputils-ping # - {ping}

Docker. Interface found

$ docker exec -it my-container cat /sys/class/net/eth0/iflink
ip ad | grep 123
#!/bin/bash
 
export containers=$(sudo docker ps --format "{{.ID}}|{{.Names}}")
export interfaces=$(sudo ip ad);
for x in $containers
        do
                export name=$(echo "$x" |cut -d '|' -f 2);
                export id=$(echo "$x"|cut -d '|' -f 1)
                export ifaceNum="$(echo $(sudo docker exec -it "$id" cat /sys/class/net/eth0/iflink) | sed s/[^0-9]*//g):"
                export ifaceStr=$( echo "$interfaces" | grep $ifaceNum | cut -d ':' -f 2 | cut -d '@' -f 1);
                echo -e "$name: $ifaceStr";
done

Docker. Show services table view

$docker ps -a --format "table {{.Names}}\t\t{{.Size}}\t\t{{.Ports}}\t\t{{.Status}}" --filter "label=com.docker.compose.project=docker-reception"
NAMES                                             SIZE                                          PORTS                                                          STATUS
docker-reception_massmess_1                       2B (virtual 44MB)                                                                                            Up 2 months
docker-reception_mysql_1                          1.92kB (virtual 406MB)                        0.0.0.0:3306->3306/tcp                                         Up 3 months
docker-reception_ldr_1                            0B (virtual 14.9MB)                                                                                          Exited (0) 4 minutes ago
mysql-exporter                                    0B (virtual 17.5MB)                           0.0.0.0:9104->9104/tcp                                         Up 3 months
docker-reception_phpgost_1                        769B (virtual 506MB)                          9000/tcp, 0.0.0.0:8080->80/tcp                                 Up 3 months
docker-reception_pma_1                            63.4kB (virtual 89.7MB)                       0.0.0.0:8081->8080/tcp                                         Up 2 months
docker-reception_nginx_1                          2B (virtual 126MB)                            0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp                       Up 3 months

Docker. determining container responsible for largest overlay directories

# huge containers overlay container size
# as root $ sudo su     # make sure json parser is installed  $ apt-get install jq -y 
 
# grab the size and path to the largest overlay dir
du /var/lib/docker/overlay2 -h | sort -h | tail -n 100 | grep -vE "overlay2$" > /tmp/large-overlay.txt
 
# construct mappings of name to hash
docker inspect $(docker ps -qa) | jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"' > /tmp/docker-mappings.txt
 
# for each hashed path, find matching container name
cat /tmp/large-overlay.txt | xargs -l bash -c 'if grep $1 /tmp/docker-mappings.txt; then echo -n "$0 "; fi'

Docker BuildKit

BuildKit

Docker monitoring

Docker monitoring Prometheus

Docker Performance

Docker Optimize

Docker multi stage builds

https://blog.alexellis.io/mutli-stage-docker-builds/

Docker Debug

Docker Backup

Docker volumes backup/restore

Docker Volume Backup

Docker Volume Restore

Docker-compose set variables in docker compose UID GID

Docker-compose backup/restore

Ddocker-compose.yml

Docker baseimage to ease creation of X graphical application containers GUI

Docker Network

Docker Traefik

Docker.Performance container perf

Docker.Swarm

#!/usr/bin/env bash
 
#args=("$@")
#echo "args:${args[*]}"
 
LOG=sz_cron_entrypoint_backup.log
 
echo $(date) > $LOG
 
IFS=$'\n'
for line in $(docker ps -a --format "{{.ID}} {{.Names}}" --filter name=UismvProd_Db)
do
        unset IFS
        array=($line)
        echo " Find container name:${array[1]}(id:${array[0]}) -> process wal-g" >> $LOG
        /usr/bin/docker exec  ${array[0]}  /home/wal-g/cron_do_backup.sh >> $LOG
done

Docker.ansible