Hey all, I was wondering where I could find the optimizations, tweaks, or modifications that certain packages installed through dietpi-software use. In my specific case, I want to check if Docker has any, so I can manually apply them for Podman, a faster, lighter, and more secure alternative to Docker.
Thanks!
Well you would need to have a look to our dietpi-software
script. There you see all steps we do for each software title.
The corresponding part of the script should be:
if To_Install 162 # Docker
then
# Detect distro
local distro='debian'
(( $G_HW_MODEL < 10 )) && (( $G_RASPBIAN )) && distro='raspbian'
# APT key
local url="https://download.docker.com/linux/$distro/gpg"
G_CHECK_URL "$url"
G_EXEC eval "curl -sSfL '$url' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-docker.gpg --yes"
# APT list
G_EXEC eval "echo 'deb https://download.docker.com/linux/$distro/ $G_DISTRO_NAME stable' > /etc/apt/sources.list.d/docker.list"
G_AGUP
# APT package
# - Mask service to prevent iptables related startup failure: https://github.com/MichaIng/DietPi/issues/6013
G_EXEC systemctl mask --now docker
G_AGI docker-ce
G_EXEC systemctl unmask docker
G_EXEC systemctl start docker.socket
# Change Docker service type to "simple": https://github.com/MichaIng/DietPi/issues/2238#issuecomment-439474766
[[ -d '/lib/systemd/system/docker.service.d' ]] || G_EXEC mkdir /lib/systemd/system/docker.service.d
G_EXEC eval "echo -e '[Service]\nType=simple' > /lib/systemd/system/docker.service.d/dietpi-simple.conf"
# Config: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file
# - Move Docker containers to dietpi_userdata
# - Log to systemd-journald (journalctl) by default with reduced log level: https://github.com/MichaIng/DietPi/issues/2388
# + containerd: https://github.com/docker/docker.github.io/issues/9091
[[ -d '/mnt/dietpi_userdata/docker-data' ]] || G_EXEC mkdir /mnt/dietpi_userdata/docker-data
if [[ -f '/etc/docker/daemon.json' ]]
then
GCI_PRESERVE=1 G_CONFIG_INJECT '"data-root":' ' "data-root": "/mnt/dietpi_userdata/docker-data",' /etc/docker/daemon.json '^\{([[:space:]]|$)'
GCI_PRESERVE=1 G_CONFIG_INJECT '"log-driver":' ' "log-driver": "journald",' /etc/docker/daemon.json '^\{([[:space:]]|$)'
GCI_PRESERVE=1 G_CONFIG_INJECT '"log-level":' ' "log-level": "warn",' /etc/docker/daemon.json '^\{([[:space:]]|$)'
GCI_PRESERVE=1 G_CONFIG_INJECT '"debug":' ' "debug": false,' /etc/docker/daemon.json '^\{([[:space:]]|$)'
else
[[ -d '/etc/docker' ]] || G_EXEC mkdir /etc/docker
echo '{
"data-root": "/mnt/dietpi_userdata/docker-data",
"log-driver": "journald",
"log-level": "warn",
"debug": false
}' > /etc/docker/daemon.json
fi
G_CONFIG_INJECT '\[debug\]' '[debug]' /etc/containerd/config.toml
GCI_PRESERVE=1 G_CONFIG_INJECT 'level[[:blank:]]*=' ' level = "warn"' /etc/containerd/config.toml '^\[debug\]'
Enable_memory_cgroup
Configure_iptables
fi
It’s kinda self-explanatory tanks to the many comments.
If you wanna know what the functions to (like G_AGUP
etc) you can have a look into this:
https://github.com/MichaIng/DietPi/blob/b510d2bfe2153417314aa0bc3ce791412eb2bf0a/dietpi/func/dietpi-globals
Great, thanks a lot! Indeed, the comments are a great attribution.
Btw: on Docker we modify storage location to point to dietpi user data. To reach same goal on Podman, you might need to install apt package containers-storage
in addition.