-
Notifications
You must be signed in to change notification settings - Fork 38
Performance issue with docker on ubuntu 20.04 LTS
Didier Roche edited this page Jun 18, 2020
·
5 revisions
If you installed Docker on Ubuntu 20.04 LTS before version 19.03.8-0ubuntu2, you may have a dataset layout dedicated to docker that is not efficient enough over time and may lead to ZSys timeout, slow boot, disk space limitations and more issues.
New installations after docker.io version 19.03.8-0ubuntu2 are not impacted, but we decided to not migrate existing installations automatically as it requires to stop docker.
This has been discussed on this bug report and directly with Docker upstream.
To migrate manually, you can run this script as root. /!\ It will stop the docker daemon. If you have a specific configuration preventing docker to be stopped, please replace the systemctl
commands accordingly.
set -eu
# Check where the closest mountpoint is (if it’s zfs)
docker_parent_mountpoint="$(findmnt -n -o SOURCE -T /var/lib/docker -t zfs || true)"
if [ -n "${docker_parent_mountpoint}" ]; then
if [ "$(zfs get mountpoint -H -o value "${docker_parent_mountpoint}")" != "/var/lib/docker" ]; then
pool="${docker_parent_mountpoint%%/*}"
# Create <currentpool>/var/lib/docker (if it doesn’t exist)
zfs create -o canmount=off "$pool"/var 2>/dev/null || true
zfs create -o canmount=off "$pool"/var/lib 2>/dev/null || true
# Migrate existing content
systemctl stop docker
mv /var/lib/docker /var/lib/docker.migrating
dockermnt="$pool"/var/lib/docker
zfs create "${dockermnt}" 2>/dev/null || true
chmod 0711 /var/lib/docker
# Migrate from older path to newer one.
mv /var/lib/docker.migrating/* /var/lib/docker/ 2>/dev/null || true
rmdir /var/lib/docker.migrating/
# Migrate datasets if they were created by ZSys
rpool="$(zfs mount | awk '$2=="/" {print $1}'| cut -d/ -f1)"
for dataset in $(zfs list -H -t filesystem -o name,mountpoint,canmount -r "$rpool"/ROOT 2>/dev/null | grep -E "/var/lib/[0-9a-f]{64}(-init)?\slegacy\son" | cut -f1); do
dockerid=${dataset##*/}
zfs rename "$dataset" "${dockermnt}/$dockerid" || true
done
# Purge their ZSys history datasets
for dataset in $(zfs list -H -t snapshot -o name -r "${dockermnt}" | grep "@autozsys_"); do
zfs destroy -R "$dataset" || true
done
systemctl start docker
fi
fi