ryansheehan / terraria

Dockerfile for terraria
MIT License
291 stars 104 forks source link

Problem connecting when running with podman; works with docker #131

Open mlandalv opened 1 year ago

mlandalv commented 1 year ago

Not sure if this is a bug or simply my lack of skills with podman, but the server works fine with docker, but not with podman. With podman it starts but it is not possible to connect. I have the same problem with both terraria:latest and terraria:vanilla-latest.

Docker

With docker the server starts fine and it's possible to connect.

docker run -it -p 7777:7777 --rm -v /opt/terraria-server/worlds:/root/.local/share/Terraria/Worlds -e WORLD_FILENAME=World.wld -v /opt/terraria-server/config:/config docker.io/ryshe/terraria:vanilla-latest

[...]

Terraria Server v1.4.4.4

Listening on port 7777
Type 'help' for a list of commands.

: Server started
192.168.1.117:39940 is connecting...
gpath.c:115: assertion 'filename != NULL' failed

gpath.c:115: assertion 'filename != NULL' failed

[nickname] has joined.
[nickname] has left.

Ports.

lsof -i -P -n
docker-pr 7460            root    4u  IPv4 174547      0t0  TCP *:7777 (LISTEN)
docker-pr 7467            root    4u  IPv6 174549      0t0  TCP *:7777 (LISTEN)

Podman

The exact same run command but with podman. The server starts but it's not possible to connect. Stuck at "Connecting to 192.168.1.66:7777".

podman run -it -p 7777:7777 --rm -v /opt/terraria-server/worlds:/root/.local/share/Terraria/Worlds -e WORLD_FILENAME=World.wld -v /opt/terraria-server/config:/config docker.io/ryshe/terraria:vanilla-latest

[...]

Terraria Server v1.4.4.4

Listening on port 7777
Type 'help' for a list of commands.

: Server started

Ports.

lsof -i -P -n
conmon    7314            root    5u  IPv4 173141      0t0  TCP *:7777 (LISTEN)

I'm using Netavark. I'm guessing this might have something to do with it.

podman info --format {{.Host.NetworkBackend}}
netavark

There's no firewall on the server and iptables is not enabled. I've tried with upnp=0 and upnp=1 in serversettings.txt.

Any help to get this to work with podman is highly appreciated.

ryansheehan commented 1 year ago

I'm not familiar with Podman, by chance do you have a port conflict or port forwarding issue?

On Thu, Oct 6, 2022 at 11:32 AM Martin Landälv @.***> wrote:

Not sure if this is a bug or simply my lack of skills with podman, but the server works fine with docker, but not with podman. With podman it starts but it is not possible to connect. I have the same problem with both terraria:latest and terraria:vanilla-latest. Docker

With docker the server starts fine and it's possible to connect.

docker run -it -p 7777:7777 --rm -v /opt/terraria-server/worlds:/root/.local/share/Terraria/Worlds -e WORLD_FILENAME=World.wld -v /opt/terraria-server/config:/config docker.io/ryshe/terraria:vanilla-latest

[...]

Terraria Server v1.4.4.4

Listening on port 7777 Type 'help' for a list of commands.

: Server started192.168.1.117:39940 is connecting... gpath.c:115: assertion 'filename != NULL' failed

gpath.c:115: assertion 'filename != NULL' failed

[nickname] has joined. [nickname] has left.

Ports.

lsof -i -P -n docker-pr 7460 root 4u IPv4 174547 0t0 TCP :7777 (LISTEN) docker-pr 7467 root 4u IPv6 174549 0t0 TCP :7777 (LISTEN)

Podman

The exact same run command but with podman. The server starts but it's not possible to connect. Stuck at "Connecting to 192.168.1.66:7777".

podman run -it -p 7777:7777 --rm -v /opt/terraria-server/worlds:/root/.local/share/Terraria/Worlds -e WORLD_FILENAME=World.wld -v /opt/terraria-server/config:/config docker.io/ryshe/terraria:vanilla-latest

[...]

Terraria Server v1.4.4.4

Listening on port 7777 Type 'help' for a list of commands.

: Server started

Ports.

lsof -i -P -n conmon 7314 root 5u IPv4 173141 0t0 TCP *:7777 (LISTEN)

I'm using Netavark. I'm guessing this might have something to do with it.

podman info --format {{.Host.NetworkBackend}} netavark

There's no firewall on the server and iptables is not enabled. I've tried with upnp=0 and upnp=1 in serversettings.txt.

Any help to get this to work with podman is highly appreciated.

— Reply to this email directly, view it on GitHub https://github.com/ryansheehan/terraria/issues/131, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB46ERYVFO3YYQDIZVWPTD3WB35K7ANCNFSM6AAAAAAQ6ZVT44 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

mlandalv commented 1 year ago

It's not a port conflict. I've also tried other ports with the same result.

I managed to get it to work when running with --network=host so it seems it isn't enough to expose port 7777, at least not for podman.

It probably has something to do with TerrariaServer.exe (and/or podman's netavark) and how it handles incoming connections. Requiring some other port range. I thought maybe enabling/disabling upnp would help, but unfortunately not.

Maybe there isn't much to be done. Feel free to close the issue if you like.

GrayEye commented 1 year ago

This comes down to a fundamental difference in how Podman handles networking vs Docker. Docker makes networking easy by natively using the host network when you spin up a container. For something like this, you can get the same functionality as Docker by doing what you have done and specifying --network=host. Those interested can read more about Podman networking here