Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@MatthiasJobst

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

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