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:
+13
-8
@@ -36,14 +36,19 @@ runs:
|
|||||||
- name: Start BuildKit container (with labels)
|
- name: Start BuildKit container (with labels)
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
docker ps -a --format '{{.Names}}' | grep -qx '${{ inputs.container_name }}' || \
|
# Recreate if a stopped/old container exists (config drift, e.g. port
|
||||||
docker run -d --name ${{ inputs.container_name }} --privileged \
|
# mapping changes, would otherwise be skipped by the name guard).
|
||||||
--network ${{ inputs.network }} \
|
# If it is already running with the right config, keep it (warm cache).
|
||||||
-p 127.0.0.1:${{ inputs.port }}:${{ inputs.port }} \
|
if [ "$(docker inspect -f '{{.State.Running}}' ${{ inputs.container_name }} 2>/dev/null)" != "true" ]; then
|
||||||
--restart unless-stopped \
|
docker rm -f ${{ inputs.container_name }} >/dev/null 2>&1 || true
|
||||||
--label com.centurylinklabs.watchtower.monitor-only=${{ inputs.monitor_only }} \
|
docker run -d --name ${{ inputs.container_name }} --privileged \
|
||||||
--label dockhand.notify=${{ inputs.dockhand_notify }} \
|
--network ${{ inputs.network }} \
|
||||||
${{ inputs.image }} --addr tcp://0.0.0.0:${{ inputs.port }}
|
-p 127.0.0.1:${{ inputs.port }}:${{ inputs.port }} \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|||||||
Reference in New Issue
Block a user