mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 10:39:38 -05:00
[Docker] HTTP_PORT ignored, changing it in app.ini fails the container #3885
Closed
opened 2025-11-02 05:29:32 -06:00 by GiteaMirror
·
12 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3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v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#3885
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DarkGhostHunter on GitHub (Sep 3, 2019).
[x]):Description
Using Docker, Gitea fails to bind to a the 80 port.
When it fails, the docker container is brought down.
This (using non-standard port for HTTP/HTTPS on a Docker Container) makes no sense at all, and trying to bind it to 80 also doesn't work. I can't think about a need of using the 3000 port, unless there is a problem on permissions (ports < 1024 are restricted to root and I assume gitea runs on the
gituser).HTTP_PORTenvironment variable is ignored.app.inigives the aforementioned log.@gary-kim commented on GitHub (Sep 3, 2019):
Rather than changing the port inside the container, you can use Docker's host mapping. So if you want to put Gitea on port 80, you would put
-p 80:3000in yourdocker runcommand.Documentation: https://docs.docker.com/config/containers/container-networking/
@DarkGhostHunter commented on GitHub (Sep 3, 2019):
Using that with other CICD containers cause them to fail because they can't reach Gitea on port 80, like when using Drone. If these change to 3000, the public request through the browser doesn't point out Gitea because is running in port 3000. This behind load balancers makes them unusable, which is probably 100% of production environments.
For example, trying to pull an automatic build from Gitea returns this:
The only workaround that I can think of is to let the Gitea starts as root inside the Docker container, allowing mapping a sub < 1024 port, but dropping privileges to the set user
RUN_USERafter the port has been bound to the container.@techknowlogick commented on GitHub (Sep 3, 2019):
drone.gitea.com, and drone.gitea.io are both behind LB's and are configured in a similar way to how @gary-kim has suggested.
You can keep HTTP_PORT as 3000, but update ROOT_URL (for example ROOT_URL=http://git.development.services.cencosud.cl ) to be a URL that doesn't have a port have so that browser requests go through a LB.
@DarkGhostHunter commented on GitHub (Sep 3, 2019):
That's a weird setup.
Anyway, this can be fixed by allowing
/app/gitea/giteato bind a port below 1024 usingsetcap. Since the installation allows to bind any number to the port, the user may find a problem when it changes the port to another one when restarting the Gitea container.To avoid this,
libcapshould be installed in the container (since it's Alpine) and let gitea the permissions to do so, without running it asroot.I'll make a PR later. For the time being, this can be fixed by using a Dockerfile:
@gary-kim commented on GitHub (Sep 3, 2019):
For the Docker container, it shouldn't matter what the internal binding is. I'm not sure why Gitea needs the ability to bind to any port inside the container.
From my experience, it's a pretty standard setup for Docker images.
@gary-kim commented on GitHub (Sep 3, 2019):
Do you have Gitea and Drone set up in a single docker-compose setup? While you could contact another container through the docker provided hostname, it generally should be the same URL used for public access, whether that be behind a reverse proxy or through the external URL. In the latter case, it doesn't matter what the internal port mapping Gitea is.
@DarkGhostHunter commented on GitHub (Sep 3, 2019):
Exactly.
The problem I'm having is that Drone, when in the same network, will only find Gitea by its name (for example,
http://gitea:3000. When it reroutes the browser to OAuth, that hostname doesn't exists (but it does ashttp://git.development.services.cencosud.cl). If I do an alias, it does work but I have to change the port number in the browser.The LB uses 80/443, so I can't bind ports. Because it's more easy to use
mail.thing.govthanthing.gov:2000for those who don't know what http is.@gary-kim commented on GitHub (Sep 4, 2019):
The way I have mine setup is with Gitea running with
-p 3000:3000and using Apache as a reverse proxy from https://git.garykim.dev to port 3000 internally and Drone accesses Gitea through the same URL. Could the LB be set up in a similar way? The idea would be that Drone also accesses through your LB.@DarkGhostHunter commented on GitHub (Sep 4, 2019):
I Understand, but the corporate firewall doesn't allow to use any other port for the machines. I'm trying to workaround this, but the only solution I have, and that works, is to just push a
setcap.@gary-kim commented on GitHub (Sep 4, 2019):
Okay, IMHO, I don't think it's worth it to add
libcapto the official Docker container because this seems like a relatively rare situation.@stale[bot] commented on GitHub (Nov 3, 2019):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
@alexrjs commented on GitHub (Oct 31, 2020):
Thanks, thats what I needed to get gitea working in docker with a macvlan to get a dhcp ip from my fritz.box router... :-)