mirror of
https://github.com/home-assistant/operating-system.git
synced 2026-09-26 03:23:35 +01:00
Corrupted Docker image layers cannot be always fixed by removing and re-pulling a single image, because layers are shared between images. The only (easy) way to recover is wiping all of Docker's storage which is currently cumbersome and requires OS shell access. Add service triggered by /mnt/data/docker/.wipe-scheduled flag file which wipes the Docker directory by atomically renaming it and deleting synchronously. If this is interrupted, docker-prepare script removes the leftovers before Docker is started on every boot. It should be noted that docker-prepare also forces the switch to containerd snapshotter after the wipe. Refs home-assistant/supervisor#6555
27 lines
818 B
Bash
Executable File
27 lines
818 B
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
# Remove leftovers of an interrupted Docker storage reset
|
|
rm -rf /mnt/data/docker.wipe.*
|
|
|
|
if [ ! -d /mnt/data/docker ] || [ -z "$(ls -A /mnt/data/docker)" ]; then
|
|
echo "[INFO] Docker data is wiped, creating containerd snapshotter flag"
|
|
touch /mnt/data/.docker-use-containerd-snapshotter
|
|
fi
|
|
|
|
DOCKERD_FLAGS=""
|
|
|
|
if [ -f /mnt/data/.docker-use-containerd-snapshotter ]; then
|
|
echo "[INFO] Using Docker containerd snapshotter"
|
|
DOCKERD_FLAGS="${DOCKERD_FLAGS} --feature containerd-snapshotter"
|
|
|
|
if [ -d /mnt/data/docker/overlay2 ]; then
|
|
echo "[INFO] Removing no longer used overlay2 directory"
|
|
# Allow the removal to fail without failing the service
|
|
rm -rf /mnt/data/docker/overlay2 || true
|
|
fi
|
|
fi
|
|
|
|
echo "DOCKERD_FLAGS=\"${DOCKERD_FLAGS}\"" > /run/dockerd.env
|