@@ -43,7 +43,7 @@ inputs:
4343 storage-driver :
4444 default : overlay2
4545 additional-dockerd-args :
46- default : " "
46+ default : " --tls=false "
4747 use-host-network :
4848 description : " Run DinD with --network host instead of publishing a TCP port."
4949 default : " false"
@@ -57,6 +57,9 @@ inputs:
5757 default : 10s
5858 wait-timeout :
5959 default : " 180"
60+ dind-image :
61+ description : " DinD image. Use a fixed version tag to avoid issues."
62+ default : " docker:27-dind"
6063
6164 # --- NEW: Optional Setup & Verification Steps ---
6265 cleanup-dind-on-start :
@@ -129,7 +132,11 @@ runs:
129132
130133 docker volume create --name "${STORAGE_VOL}" --label "com.github.dind=1" --label "com.github.repo=${GITHUB_REPOSITORY}" >/dev/null
131134 docker volume create --name "${EXECROOT_VOL}" --label "com.github.dind=1" --label "com.github.repo=${GITHUB_REPOSITORY}" >/dev/null
135+
136+ # Clean up any existing DinD containers
137+ docker ps -a -q --filter "label=com.github.dind=1" | xargs -r docker rm -f -v 2>/dev/null || true
132138 docker rm -f -v "$NAME" 2>/dev/null || true
139+ sleep 2
133140
134141 NET_ARGS=""
135142 PUBLISH_ARGS="-p ${BIND}:${PORT}:${PORT}"
@@ -138,6 +145,8 @@ runs:
138145 PUBLISH_ARGS=""
139146 fi
140147
148+ IMAGE="${{ inputs.dind-image || 'docker:27-dind' }}"
149+
141150 docker run -d --privileged --name "$NAME" \
142151 --cgroupns=host \
143152 -e DOCKER_TLS_CERTDIR= \
@@ -152,10 +161,11 @@ runs:
152161 --health-interval=${HI} \
153162 --health-retries=${HR} \
154163 --health-start-period=${HSP} \
155- docker:dind \
164+ "${IMAGE}" \
156165 --host=tcp://0.0.0.0:${PORT} \
157166 --host=unix:///var/run/docker.sock \
158167 --storage-driver=${SD} \
168+ --iptables=false \
159169 --exec-root=/execroot ${EXTRA}
160170
161171 {
@@ -206,20 +216,20 @@ runs:
206216 run : |
207217 set -euo pipefail
208218 NAME="${{ inputs.container-name || 'dind-daemon' }}"
209-
219+
210220 # Use host daemon to inspect the DinD container
211221 nm=$(docker inspect -f '{{.HostConfig.NetworkMode}}' "$NAME")
212222 echo "DinD NetworkMode=${nm}"
213223
214224 # Try to find the bridge network IP
215225 ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$NAME" || true)
216-
226+
217227 # If still empty, likely host networking -> use loopback
218228 if [[ -z "${ip}" || "${nm}" == "host" ]]; then
219229 echo "No bridge IP found or using host network. Falling back to 127.0.0.1."
220230 ip="127.0.0.1"
221231 fi
222-
232+
223233 echo "Discovered DinD IP: ${ip}"
224234 echo "dind-ip=${ip}" >> "$GITHUB_OUTPUT"
225235
@@ -237,7 +247,7 @@ runs:
237247 hostport=$(docker port redis-smoke 6379/tcp | sed 's/.*://')
238248 echo "Redis container started, mapped to host port ${hostport}"
239249 echo "Probing connection to ${DIND_IP}:${hostport} ..."
240-
250+
241251 timeout 5 bash -c 'exec 3<>/dev/tcp/$DIND_IP/'"$hostport"
242252 if [[ $? -eq 0 ]]; then
243253 echo "TCP connection successful. Port mapping is working."
@@ -272,4 +282,4 @@ runs:
272282 shell : bash
273283 run : |
274284 echo "DOCKER_HOST=${{ steps.set-output.outputs.docker-host }}" >> "$GITHUB_ENV"
275- echo "DIND_IP=${{ steps.discover-ip.outputs.dind-ip }}" >> "$GITHUB_ENV"
285+ echo "DIND_IP=${{ steps.discover-ip.outputs.dind-ip }}" >> "$GITHUB_ENV"
0 commit comments