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
20 lines
506 B
Bash
Executable File
20 lines
506 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
DOCKER_DIR="/mnt/data/docker"
|
|
|
|
if findmnt /var/lib/docker > /dev/null; then
|
|
echo "[ERROR] Unable to reset Docker storage while /var/lib/docker is mounted"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -e "${DOCKER_DIR}" ]; then
|
|
WIPED_DIR="${DOCKER_DIR}.wipe.$(date +%s)"
|
|
echo "[INFO] Moving Docker storage to ${WIPED_DIR}"
|
|
mv "${DOCKER_DIR}" "${WIPED_DIR}"
|
|
fi
|
|
|
|
# Leftovers are removed by docker-prepare if this is interrupted
|
|
echo "[INFO] Removing old Docker storage"
|
|
rm -rf "${DOCKER_DIR}".wipe.*
|