Skip to content

Docker health check is not working when using a proxy #7529

Closed
MatthiasJobst/gogs
#1

Description

@MatthiasJobst

Gogs version

0.14.0+dev

Git version

  • Server: 2.38.5
  • Client: 2.39.1.windows.1

Operating system

Alpine 3.17

Database

SQLite 3

Describe the bug

This problem exists when using a docker image in a corporate environment. Running docker psyields:
gogs/gogs "/app/gogs/docker/st..." 5 days ago Up 8 minutes (unhealthy)

The reason is that in the health check curl is looking for localhost with a specific port. I assume that the proxy is called to resolve localhost:3000. This is correctly resolved, but by changing the port to 10880 -p 10880:3000 when connecting externally, the curl will not be fulfilled. The health check reports unhealthy.

To reproduce

The problem occurs when using a proxy to connect to the internet. This can be achieved with running the docker image using the parameter:
-e HTTP_PROXY="host.docker.internal" -e HTTPS_PROXY="host.docker.internal"

Expected behavior

It is expected that docker ps shows the container as healthy.

Additional context

In the Dockerfile the health check should be written as:
HEALTHCHECK CMD (curl --noproxy localhost -o /dev/null -sS http://localhost:3000/healthcheck) || exit 1

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added a commit that references this issue on Aug 16, 2023
    12519f6
  2. added a commit that references this issue on Aug 16, 2023
    2500d20
  3. locked as resolved and limited conversation to collaborators on Nov 15, 2023
  4. added a commit that references this issue on Jan 31, 2026
    b7b83ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址