diff --git a/Dockerfile b/Dockerfile index 82cee67..a42d5eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,9 +33,9 @@ RUN chown -R nginx:nginx /usr/share/nginx/html && \ # Expose port 80 EXPOSE 80 -# Health check +# Health check (127.0.0.1 to avoid IPv6 localhost when nginx listens on IPv4 only) HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1 + CMD wget --quiet --tries=1 --spider http://127.0.0.1/ || exit 1 # Run nginx in foreground CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml index b19c1a1..862e870 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: pull_policy: always restart: unless-stopped healthcheck: - test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"] + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://127.0.0.1/"] interval: 30s timeout: 3s start_period: 5s