docker-minecraft-bedrock-server icon indicating copy to clipboard operation
docker-minecraft-bedrock-server copied to clipboard

Server not showing up under LAN when specific IP address selected for port

Open kchenery opened this issue 5 years ago • 11 comments

So I am trying to run more than one version of the server in docker. One that is set to creative mode and one that is set to survival mode.

To allow port 19132 to be the default I added a couple of IP addresses to my host. Then I bind a specific IP address to each docker container. When I do this the server does not show up under LAN games. If I do not specify the IP address it shows up fine.

For example...

This command will work fine:

docker run  --name mc-survival --restart=unless-stopped  -e EULA=TRUE -v /opt/docker-minecraft/survival:/data -p 19132:19132/udp itzg/minecraft-bedrock-server

This command will run the container fine and I can use it if I define it as a server but it does not show up as a LAN game:

docker run  --name mc-survival --restart=unless-stopped  -e EULA=TRUE -v /opt/docker-minecraft/survival:/data -p 192.168.94.13:19132:19132/udp itzg/minecraft-bedrock-server

I've specified the port in server.properties. I also use a whitelist.json but that shouldnt matter.

Are there other ports I need to expose on that IP address?

As mentioned the server runs fine. Can connect and use it if I manually specify it. I just want it to show up under LAN games so that my kids can find it easily (and any others I create).

kchenery avatar Feb 07 '20 06:02 kchenery

Have tried mapping different ports (e.g. 19142 instead but that doesnt work either). Seems only 19132 will show up under LAN games :(

kchenery avatar Feb 07 '20 06:02 kchenery

That's a great idea with adding multiple IP addresses on the host. I would recommend debugging by running sudo tcpdump -v udp port 19132 to see if the broadcast packets (and others) are making it to the host.

Unfortunately I can't work on recreating this since I recently stopped my Xbox Gold membership and that seems to have prevented LAN games from showing up at all for me :( .

itzg avatar Feb 07 '20 18:02 itzg

Ahh good call with tcpdump.

I had fired up Wireshark on the PC and could see the broadcasts going out but nothing back from the host when the IP address is specified. The tcpdump doesnt reveal anything either. Tried disabling the firewall on the host (which is Ubuntu BTW) - no change with that either.

So it only responds when no IP is specified (or 0.0.0.0 is specified).

At a bit of a loss how to check things with the container - bit new to Docker.

kchenery avatar Feb 08 '20 06:02 kchenery

Previously my normal setup "wasn't working" because I didn't have the container running :) After adding an IP address to my host's (also Ubuntu) interface and using a -p with that address I'm guessing I'm seeing the same as you in tcpdump: just broadcast packets coming in but no responses.

Using sudo lsof -i:19132 I can see the docker-proxy process is supposedly listening:

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 912 root    4u  IPv4 563066      0t0  UDP nuc:19132 

One thing that looked suspicious is that when using arp the HWaddress of the IP address I added shows (incomplete).

At this point I'm left wondering if it's a multi-homing issue in general or something with docker-proxy not fully supporting it.

itzg avatar Feb 08 '20 15:02 itzg

Ok... I have done some reading (and a lot of Googling) and come up with a working solution for me!

When looking up how to assign a static IP address to a container you will find this SO quesiton/answer: https://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container The very last response spun me off to learning about macvlan in docker here: https://docs.docker.com/network/macvlan/

That looked very promising. So I added a new macvlan to the host with: docker network create -d macvlan --subnet=192.168.94.0/24 --gateway=192.168.94.1 -o parent=ens3 pub_chenery

This gives the same range as the host

I then removed the IP addresses from the host I had assigned before (see earlier post).

Removed the existing containers and then started them up like this:

docker run -d --name mc-survival --restart=unless-stopped  -e EULA=TRUE -v /opt/docker-minecraft/survival:/data --net pub_chenery --ip=192.168.94.12 itzg/minecraft-bedrock-server

Did the same for the second container (different name, path and IP address of course). And joy they both started with the two IPs I wanted.

And best of all I can now see them on my network as they've got their own "public" IP on my subnet. They are pingable too. Didnt have to map any ports as you'll have seen in the command.

For me the hint was on the docker page about some services needing access to the network card with the wording:

expect to be directly connected to the physical network

kchenery avatar Feb 11 '20 00:02 kchenery

That's a really great discovery and thanks for posting all of the information.

itzg avatar Feb 11 '20 17:02 itzg

So weirdly the host cant ping the addresses (other clients on the network can just fine). Im not sure why that is - perhaps cause the gateway is defined as the IP address of the host. That needs a bit of investigation.

Anyway - feel free to close this issue. Might be worth adding some documentation about how to run multiple instances and still make them discoverable by Minecraft though 😃

kchenery avatar Feb 11 '20 23:02 kchenery

I run into the same problem on my MBP server, and my solution is to specify -p 0.0.0.0:19132:19132/udp instead of the default localhost. Then this server shows up in my LAN world as well as a dedicated server.

ycshao avatar May 13 '20 21:05 ycshao

So weirdly the host cant ping the addresses (other clients on the network can just fine). Im not sure why that is - perhaps cause the gateway is defined as the IP address of the host. That needs a bit of investigation.

Anyway - feel free to close this issue. Might be worth adding some documentation about how to run multiple instances and still make them discoverable by Minecraft though

Fyi, macvlan usually has issues with host communication even in vm's. Why, I don't remember but there is some router nat magic you can use to circumvent if needed.

maxfield-allison avatar Jul 17 '20 04:07 maxfield-allison

I had a very similar issue, however, in a kubernetes cluster. What fixed it for me, was setting the container's network in host mode (in k8s context, hostNetwork=true).

borger avatar Jul 19 '21 03:07 borger

Ok... I have done some reading (and a lot of Googling) and come up with a working solution for me!

When looking up how to assign a static IP address to a container you will find this SO quesiton/answer: https://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container The very last response spun me off to learning about macvlan in docker here: https://docs.docker.com/network/macvlan/

That looked very promising. So I added a new macvlan to the host with: docker network create -d macvlan --subnet=192.168.94.0/24 --gateway=192.168.94.1 -o parent=ens3 pub_chenery

This gives the same range as the host

I then removed the IP addresses from the host I had assigned before (see earlier post).

Removed the existing containers and then started them up like this:

docker run -d --name mc-survival --restart=unless-stopped  -e EULA=TRUE -v /opt/docker-minecraft/survival:/data --net pub_chenery --ip=192.168.94.12 itzg/minecraft-bedrock-server

Did the same for the second container (different name, path and IP address of course). And joy they both started with the two IPs I wanted.

And best of all I can now see them on my network as they've got their own "public" IP on my subnet. They are pingable too. Didnt have to map any ports as you'll have seen in the command.

For me the hint was on the docker page about some services needing access to the network card with the wording:

expect to be directly connected to the physical network

I'm fighting with this issue in the last couple of days, but finally I found your comment. This is still working with Minecraft Bedrock 1.20.31.01! Thank you!

zolkiss avatar Oct 03 '23 19:10 zolkiss