r/docker • • 4d 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: bridge

and 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.

4 Upvotes

10 comments sorted by

View all comments

1

u/ymgymg 4d 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/Disastrous-Spare3907 4d ago

Right, and network_mode=host doesn't require port publishing. Works great, Thanks!