fix: recreate buildkitd when not running (config drift)

The name-exists guard skipped recreation when a stopped container
from a previous failed run existed — e.g. one created before the
port mapping was added, leaving 127.0.0.1:8375 with no listener.

New logic: recreate the container whenever it is not running;
keep it (warm cache) when it is already up.
This commit is contained in:
2026-09-01 13:29:26 +02:00
parent 7c97a428ae
commit 7841e69c38
+6 -1
View File
@@ -36,7 +36,11 @@ runs:
- name: Start BuildKit container (with labels)
shell: bash
run: |
docker ps -a --format '{{.Names}}' | grep -qx '${{ inputs.container_name }}' || \
# Recreate if a stopped/old container exists (config drift, e.g. port
# mapping changes, would otherwise be skipped by the name guard).
# If it is already running with the right config, keep it (warm cache).
if [ "$(docker inspect -f '{{.State.Running}}' ${{ inputs.container_name }} 2>/dev/null)" != "true" ]; then
docker rm -f ${{ inputs.container_name }} >/dev/null 2>&1 || true
docker run -d --name ${{ inputs.container_name }} --privileged \
--network ${{ inputs.network }} \
-p 127.0.0.1:${{ inputs.port }}:${{ inputs.port }} \
@@ -44,6 +48,7 @@ runs:
--label com.centurylinklabs.watchtower.monitor-only=${{ inputs.monitor_only }} \
--label dockhand.notify=${{ inputs.dockhand_notify }} \
${{ inputs.image }} --addr tcp://0.0.0.0:${{ inputs.port }}
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4