Gogs is Serving Web Resources From the Docker Gateway IP Instead of the Docker Host IP

Hello, here is the info.

App version: 0.11.90.0801
App URL http://192.168.1.158:10090/
Domain 192.168.1.158
Offline mode (No check mark)
Require sign in view (Check mark)
Disable Registration (Check mark)

Created the docker container with this command:
docker create --name=gogs -p 10091:22 -p 10090:3000 -v gogs:/data gogs/gogs
(I created a volume called gogs before)

Here are the initial setup info:

It connects to the database fine and everything is fine when I first set it up. I was able to access it with the domain ip address above. Created a new user, forwarded my ports and had my friend from outside of my network be able to create a repository. I was able to see the repositories without being signed in so I restarted my Gogs docker container and I can no longer access it with the App URL ( http:// 192.168.1.158:10090 ).

Going to the host server, I can not login with that ip address but if I use the docker network ip (http:// 172.xxx.xxx.xxx:10090) it works just fine. For some reason it does not want to allow outside access even though that network is bridged and I can access the other containers connected to the network just fine.

Thank you

Hi,

Based on this command, you should set “HTTP Port” to 3000, not 10090, otherwise this mapping would do nothing. (But I’m not sure what side effect could be)

You should set the “Application URL” to whatever way you can access the container. Gogs does not know/care which IP it binds to, it only binds the port you define (in your case, it is 10090)

Thanks for the response. In docker -p (port mapping) uses external-port:internal-port syntax so it shouldn’t matter what I set the external port too because it forwards to the internal port of 3000.

I can access it via port 10090 but only on the internal docker ip.

Are you advising me to set the application URL to the internal docker ip (172.xxx) and not the public host ip (192.xxx)?
Thank you again

image

The problem is, based on configuration in the screenshot, Gogs will try to listen on 10090 not 3000 inside the container.

If “(172.xxx)” allows connection from other PCs, then yes. Ideally, you need a reverse proxy software (e.g. NGINX, Apache) to do the request forwarding from outside to Docker containers.

Ok I figured it out, thank you. So here is what I did.
I changed the http port inside of data/gogs/config/app.ini to 3000 (was 10090 before)
I also changed the Domain to the host ip
I also changed the root url to DomainIP:3000

I think when you set up Gogs in the web GUI you need to leave 3000 alone. I am accessing gogs from my computer now with the server host ip address and port 10090 (cause docker is forwarding it to the container at port 3000).

Thank you very much :slight_smile:
(Side note, pm me if you want me to make some video tutorials about setting up Gogs. I have done it before with other software and would be happy to make some for gogs :slight_smile: )

1 Like

Yeah, if you don’t mind take some time, you should definitely feel free to do it and I can add a link in the README to the video!