r/docker • u/Disastrous-Spare3907 • 14d ago
Server is only accessible on host mode or when using container addresses
SOLVED, see here: https://www.reddit.com/r/docker/s/92gXpeXGTe. This post will self-destruct eventually.
Here is my docker-compose.yaml
name: tactics
services:
server:
container_name: server
build:
dockerfile: server.Dockerfile
ports:
- "8000:8000"
networks:
- backend
networks:
backend:
driver: bridgeand my server.Dockerfile
debian:bookworm-slim
ENV HOME=/root
ENV PATH="$PATH:$HOME/bin"
WORKDIR $HOME/bin
COPY Server.x86_64 Server.x86_64 ./
ENTRYPOINT ["/root/bin/Server.x86_64", "--headless", "--verbose"]I create the Godot Server on a port, and create a Godot Client that connects to the same port.
If I use an address that refers directly to the container (the one shown by this https://stackoverflow.com/a/20686101) the connection is successful.
Or if I rewrite the compose to use host network mode, the connection is successful.
If I use any other address (0.0.0.0,, localhost, my public IP, my private IP), it times out.
Some suggestions have been to bind to 0.0.0.0, but I am not sure the effects of that or how it would be done in compose.
I am on an Ubuntu machine. I suppose I could also deploy to some cheap server farm. Any help is appreciated, including "don't worry about it and just use host / direct container address, here's why".
EDIT: btw I seemingly enabled br_netfilter as it was disabled, as suggested here: https://stackoverflow.com/a/60897412. Might be relevant. Didn't help though.
5
u/encbladexp 14d ago
If your compose contained only
1234:1234this means you already bound your service to 0.0.0.0 (from a container perspective).And of course, a service within the container needs to listen on 0.0.0.0, so it could be forwarded.
And we talk about Docker Engine on your Ubuntu box, not this horrible Docker Desktop mess, right?
1
u/ahumannamedtim 14d ago
You mapped a host port too right? Like 80:80 for example?
Censoring the port isn't really necessary. Tools like nmap that can scan for open ports anyway, it's not really a secret.
1
u/ymgymg 14d ago
Godot's multiplayer peer uses ENet, which is UDP, and "8000:8000" in compose only publishes TCP. Change it to "8000:8000/udp" and it should work without host mode.
1
u/dadarkgtprince 14d ago
Is your backend network external?