fix: Docker healthcheck IPv6 connection refused

Changed healthcheck from localhost to 127.0.0.1 to force IPv4 connection.
The issue occurred because 'localhost' resolves to IPv6 (::1) but nginx
only listens on IPv4 by default, causing healthchecks to fail.

Error before fix:
  Connecting to localhost ([::1]:80)
  wget: can't connect to remote host: Connection refused

Updated both Dockerfile and docker-compose.yml for consistency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-17 09:12:30 +01:00
parent 5e84f5d1f8
commit 61d2276fad
2 changed files with 3 additions and 3 deletions

View File

@@ -48,9 +48,9 @@ RUN chown -R nginx:nginx /usr/share/nginx/html && \
# Expose port 80
EXPOSE 80
# Health check
# Health check (use 127.0.0.1 to force IPv4)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1/ || exit 1
# Run nginx
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -11,7 +11,7 @@ services:
- "80:80"
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/"]
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1/"]
interval: 30s
timeout: 10s
retries: 3