Skip to content

Commit 49ef9c0

Browse files
fix(healthcheck): probe container IP instead of localhost (#100) (#113)
The app binds to the container interface (e.g. 172.x.x.x) rather than 127.0.0.1. Healthcheck against localhost fails inside the container. Change: probe container IP via `hostname -i`, force IPv4 (-4), and increase start_period/retries to avoid startup flakiness. Refs #100.
1 parent 2963528 commit 49ef9c0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ USER node
4444

4545
# Expose port and add healthcheck
4646
EXPOSE 3000
47-
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:3000 || exit 1
47+
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=5 \
48+
CMD IP=$(hostname -i | awk '{print $1}'); curl -fsS -4 "http://$IP:${PORT:-3000}" || exit 1
4849

4950
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)