1
0
mirror of https://github.com/home-assistant/operating-system.git synced 2025-12-20 02:18:37 +00:00

Start Supervisor container with its cidfile mounted to /run/cid (#4276)

Use the --cidfile Docker CLI argument when starting the container and
bind-mount the generated file containing full ID of the container to the
container itself.

Using --mount instead of --volume is needed, as --volume is racy and creates
empty directory volume at the destination path instead.

This is prerequisite for home-assistant/supervisor#6006 but can come handy for
other cases too.
This commit is contained in:
Jan Čermák
2025-09-09 20:16:11 +02:00
committed by GitHub
parent 9a1e0015d8
commit 0e3fd2c021

View File

@@ -11,6 +11,7 @@ set -e
# Init supervisor
SUPERVISOR_DATA=/mnt/data/supervisor
SUPERVISOR_STARTUP_MARKER="/run/supervisor/startup-marker"
SUPERVISOR_CIDFILE="${SUPERVISOR_DATA}/hassio_supervisor.cid"
SUPERVISOR_STARTSCRIPT_VERSION="/mnt/data/.hassos-supervisor-version"
SUPERVISOR_IMAGE="ghcr.io/home-assistant/${SUPERVISOR_ARCH}-hassio-supervisor"
@@ -87,12 +88,18 @@ fi
# If Supervisor container is missing, create it
if [ -z "${SUPERVISOR_CONTAINER_ID}" ]; then
# We need to remove the CID file here, Docker will refuse to start if the
# file is present. Single instance is ensured by other code paths.
[ -f "${SUPERVISOR_CIDFILE}" ] && rm -f "${SUPERVISOR_CIDFILE}"
echo "[INFO] Creating a new Supervisor container..."
# shellcheck disable=SC2086
docker container create \
--name hassio_supervisor \
--privileged --security-opt apparmor="hassio-supervisor" \
--oom-score-adj=-300 \
--cidfile "${SUPERVISOR_CIDFILE}" \
--mount type=bind,src="${SUPERVISOR_CIDFILE}",dst=/run/cid,readonly \
-v /run/docker.sock:/run/docker.sock:rw \
-v /run/containerd/containerd.sock:/run/containerd/containerd.sock:rw \
-v /run/systemd/journal/socket:/run/systemd/journal/socket:rw \