Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container won't start on a fresh vm - "Port may be in use" #326

Closed
seriousrob opened this issue May 29, 2023 · 9 comments
Closed

Container won't start on a fresh vm - "Port may be in use" #326

seriousrob opened this issue May 29, 2023 · 9 comments

Comments

@seriousrob
Copy link

Hi everyone,

i'm having trouble with the deployment of a new bedrock server on a fresh ubuntu 22.04 LTS vm.

I just used the default deployment command

docker run -d -it -e EULA=TRUE -p 19132:19132/udp -v mc-bedrock-data:/data itzg/minecraft-bedrock-server

but i will get a log like this from portainer:

DEBU[0000] Using /data to match uid and gid
DEBU[0000] Resolved UID=0 from match path
DEBU[0000] Resolved GID=0 from match path
Looking up latest version...
Downloading Bedrock server version 1.19.83.01 ...
Starting Bedrock server...
NO LOG FILE! - setting up server logging...
[2023-05-29 09:06:10:330 INFO] Starting Server
[2023-05-29 09:06:10:330 INFO] Version 1.19.83.01
[2023-05-29 09:06:10:330 INFO] Session ID 2013ee82-5cbf-463a-935c-32739b3bc680
[2023-05-29 09:06:10:330 INFO] Build ID 1.19.83
[2023-05-29 09:06:10:330 INFO] Branch r/19_u8
[2023-05-29 09:06:10:330 INFO] Commit ID c184ec32505984a38099320b43fd54425c2e4f5d
[2023-05-29 09:06:10:330 INFO] Configuration Publish
[2023-05-29 09:06:10:331 INFO] Level Name: Bedrock level
[2023-05-29 09:06:10:333 INFO] Game mode: 0 Survival
[2023-05-29 09:06:10:333 INFO] Difficulty: 1 EASY
[2023-05-29 09:06:10:376 INFO] opening worlds/Bedrock level/db
[2023-05-29 09:06:11:367 ERROR] Port [19132] may be in use by another process. Free up port and re-run program
[2023-05-29 09:06:11:367 ERROR] Port [19133] may be in use by another process. Free up port and re-run program
[2023-05-29 09:06:11:367 ERROR] Exiting program

I deployed different containers without issues on other machines, including Plex and Pihole but this one is giving me some headaches.

Any hints why this happens? Like i said, the vm is a fresh install and nothing is using that specific port.

regards
Robert

@itzg
Copy link
Owner

itzg commented May 29, 2023

FWIW this issue sounds familiar, but can't remember seeing if there were any solutions. You may need to search through Mojang BDS issues.

@seriousrob
Copy link
Author

Thanks for your answer. Apparently it only happens inside a vm. It doesn't happen on my actual 22.04 LTS server. I have it running now next to HA/PiHole/Plex without issues.

I tried to search the Mojang issues but couldn't find something useful after briefly looking for a proper result. I'll close this one for now.

@kaihendry
Copy link

kaihendry commented Jun 22, 2023

I just ran into this whilst running:

docker run -d -it --name bds-flat-creative \
  -e EULA=TRUE -e LEVEL_TYPE=flat -e GAMEMODE=creative \
  -p 19132:19132/udp itzg/minecraft-bedrock-server

As found in the README. I'm not running in a VM btw.

❯ docker logs 1375a078bf1a
DEBU[0000] Using /data to match uid and gid
DEBU[0000] Resolved UID=0 from match path
DEBU[0000] Resolved GID=0 from match path
Looking up latest version...
Downloading Bedrock server version 1.20.1.02 ...
2023/06/22 04:13:18 Setting gamemode to creative in server.properties
2023/06/22 04:13:18 Setting level-type to FLAT in server.properties
Starting Bedrock server...
NO LOG FILE! - setting up server logging...
[2023-06-22 04:13:18:265 INFO] Starting Server
[2023-06-22 04:13:18:265 INFO] Version: 1.20.1.02
[2023-06-22 04:13:18:265 INFO] Session ID: 5f7ff21b-b3ec-4fd6-b38c-a5abf49240b7
[2023-06-22 04:13:18:265 INFO] Build ID: 16132644
[2023-06-22 04:13:18:265 INFO] Branch: r/20
[2023-06-22 04:13:18:265 INFO] Commit ID: 057f63795f118affe392afd6d293a2c7ff7030ca
[2023-06-22 04:13:18:265 INFO] Configuration: Publish
[2023-06-22 04:13:18:266 INFO] Level Name: Bedrock level
[2023-06-22 04:13:18:267 INFO] Game mode: 1 Creative
[2023-06-22 04:13:18:267 INFO] Difficulty: 1 EASY
[2023-06-22 04:13:18:268 INFO] Content logging to console is enabled.
[2023-06-22 04:13:18:440 INFO] Opening level 'worlds/Bedrock level/db'
[2023-06-22 04:13:19:234 ERROR] Port [19132] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
[2023-06-22 04:13:19:235 ERROR] Port [19133] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
[2023-06-22 04:13:19:235 ERROR] Exiting program

docker run --rm -it -e EULA=TRUE itzg/minecraft-bedrock-server should just work right?

❯ docker info
Client:
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.11.0
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.19.0
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 36
  Running: 0
  Paused: 0
  Stopped: 36
 Images: 86
 Server Version: 24.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 0cae528dd6cb557f7201036e9f43420650207b58.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.3.8-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 14.41GiB
 Name: t14g3
 ID: 3KKL:ANA3:MQRT:26AL:AW35:6OOP:2KJJ:6SJQ:653D:JN2H:7B56:DFWP
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

I filed a bug here: https://bugs.mojang.com/browse/MCPE-172167

@josephdpurcell
Copy link
Contributor

Woe is me! I just ran into this issue.

mc2_2  | [2024-09-14 16:47:51:316 INFO] Starting Server
mc2_2  | [2024-09-14 16:47:51:316 INFO] Version: 1.21.23.01
mc2_2  | [2024-09-14 16:47:51:316 INFO] Session ID: 00af90ca-c763-432b-962b-5e057fa4a56b
mc2_2  | [2024-09-14 16:47:51:316 INFO] Build ID: 27331400
mc2_2  | [2024-09-14 16:47:51:316 INFO] Branch: r/21_u2
mc2_2  | [2024-09-14 16:47:51:316 INFO] Commit ID: bdba44b4fca5831203b34416d2ec239572c45330
mc2_2  | [2024-09-14 16:47:51:316 INFO] Configuration: Publish
mc2_2  | [2024-09-14 16:47:51:316 INFO] Level Name: Bedrock level
mc2_2  | [2024-09-14 16:47:51:318 INFO] No CDN config file found for dedicated server
mc2_2  | [2024-09-14 16:47:51:318 INFO] Game mode: 1 Creative
mc2_2  | [2024-09-14 16:47:51:318 INFO] Difficulty: 0 PEACEFUL
mc2_2  | [2024-09-14 16:47:51:319 INFO] Content logging to console is enabled.
mc2_2  | [2024-09-14 16:47:51:505 INFO] Opening level 'worlds/Bedrock level/db'
mc2_2  | [2024-09-14 16:47:51:509 INFO] [SERVER] Pack Stack - None
mc2_2  | [2024-09-14 16:47:51:758 ERROR] Port [19139] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
mc2_2  | [2024-09-14 16:47:51:758 ERROR] Port [19140] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
mc2_2  | [2024-09-14 16:47:51:758 ERROR] Exiting program

I've tried it many ways, using the docker run example, docker compose example, and the docker compose files I've used for a while. Everything was happy until today.

The only thing I can think of is my current user was added to the docker group today per the guidance here: https://docs.docker.com/engine/install/linux-postinstall/. Prior to today I was running docker as root, which is not advised, so I decided to switch.

I've tried using root instead of my user and same result.

My host machine does not have 19132 nor 19133 ports in use. I've tried modifying the port using SERVER_PORT: '19139' and SERVER_PORT_V6: '19140' with no luck, as you can see above.

I tried using image docker pull itzg/minecraft-bedrock-server:2024.5.0 and 2023.8.1 both with the same error.

I don't have another machine I can try this on. I'm on Ubuntu 24.04.

$ docker --version
Docker version 27.2.1, build 9e34c9b

$ docker compose version
Docker Compose version v2.29.2

All of my Minecraft servers are dead right now because of this issue.

@seriousrob If you have any suggestions or advice I would greatly appreciate it!

@josephdpurcell
Copy link
Contributor

I am doing some debugging... I modified the docker-compose.yml to have:

    entrypoint: ["bash"]

Then docker compose up hangs, which is fine, probably expected because I'm not sure what I'm doing exactly. In a new terminal I run:

docker exec -it mc2_2 /bin/bash

That gets me into the box. Then some debugging. First I try to run the entrypoint myself manually:

Output
root@6eb81c38b730:/data# /usr/local/bin/entrypoint-demoter --match /data --debug --stdin-on-term stop /opt/bedrock-entry.sh
DEBU[0000] Using /data to match uid and gid             
DEBU[0000] Resolved UID=0 from match path               
DEBU[0000] Resolved GID=0 from match path               
Looking up latest version...
Updating permissions
Setting allow list
Starting Bedrock server...
NO LOG FILE! - setting up server logging...
[2024-09-14 16:57:48:973 INFO] Starting Server
[2024-09-14 16:57:48:973 INFO] Version: 1.21.23.01
[2024-09-14 16:57:48:973 INFO] Session ID: e3cb8446-dba5-4360-8379-2773acf97f35
[2024-09-14 16:57:48:973 INFO] Build ID: 27331400
[2024-09-14 16:57:48:973 INFO] Branch: r/21_u2
[2024-09-14 16:57:48:973 INFO] Commit ID: bdba44b4fca5831203b34416d2ec239572c45330
[2024-09-14 16:57:48:973 INFO] Configuration: Publish
[2024-09-14 16:57:48:973 INFO] Level Name: Bedrock level
[2024-09-14 16:57:48:974 INFO] No CDN config file found for dedicated server
[2024-09-14 16:57:48:974 INFO] Game mode: 1 Creative
[2024-09-14 16:57:48:974 INFO] Difficulty: 0 PEACEFUL
[2024-09-14 16:57:48:974 INFO] Content logging to console is enabled.
[2024-09-14 16:57:49:152 INFO] Opening level 'worlds/Bedrock level/db'
[2024-09-14 16:57:49:156 INFO] [SERVER] Pack Stack - None
[2024-09-14 16:57:49:403 ERROR] Port [19139] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
[2024-09-14 16:57:49:403 ERROR] Port [19140] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
[2024-09-14 16:57:49:403 ERROR] Exiting program

Same error I see when I boot the container so thats good.

Now I look if theres anything listening on ports and I see nothing. So I use nc to listen on 19132 and it works?!

Output
# Install stuff:
root@6eb81c38b730:/data# apt-get update
root@6eb81c38b730:/data# apt-get install netcat-openbsd net-tools

# Anything running?
root@6eb81c38b730:/data# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.11:46349        0.0.0.0:*               LISTEN      -                   
udp        0      0 127.0.0.11:39232        0.0.0.0:*                           -   

# I can listen on 19132 and hit it from a browser
root@6eb81c38b730:/data# nc -l 0.0.0.0 19132
GET / HTTP/1.1
Host: localhost:19132
User-Agent: Mozilla/REDACTED
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Connection: keep-alive
Cookie: REDACTED
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Priority: u=0, i

So it seems obvious to me that something COULD run on that port, its just not for some reason!?

@josephdpurcell
Copy link
Contributor

More info... I was able to figure out that the entrypoint command is ULTIMATELY running this:

root@6eb81c38b730:/data# /data/bedrock_server-1.21.23.01

And that gives the same error. So, its definitely not something special about this docker-minecraft-bedrock-server project, necessarily. Its something about bedrock_server-1.21.23.01 which is the thing downloaded by this project. Perhaps https://bugs.mojang.com/browse/BDS-18482 really is the proper place for discussing the bug.

@josephdpurcell
Copy link
Contributor

I found an older server that I had shutdown but had pinned the version to VERSION: '1.20.81.01' and when I boot it I get:

mc3_3  | [2024-09-14 17:15:04:457 INFO] Starting Server
mc3_3  | [2024-09-14 17:15:04:457 INFO] Version: 1.20.81.01
mc3_3  | [2024-09-14 17:15:04:457 INFO] Session ID: 049e4afe-d713-4ceb-9a52-81b5ce4da457
mc3_3  | [2024-09-14 17:15:04:457 INFO] Build ID: 24130113
mc3_3  | [2024-09-14 17:15:04:457 INFO] Branch: r/20_u8
mc3_3  | [2024-09-14 17:15:04:457 INFO] Commit ID: a9081c5429038dcf3f26269f7351d89f75cfb331
mc3_3  | [2024-09-14 17:15:04:457 INFO] Configuration: Publish
mc3_3  | [2024-09-14 17:15:04:457 INFO] Level Name: Bedrock level
mc3_3  | [2024-09-14 17:15:04:458 INFO] No CDN config file found for dedicated server
mc3_3  | [2024-09-14 17:15:04:458 INFO] Game mode: 1 Creative
mc3_3  | [2024-09-14 17:15:04:458 INFO] Difficulty: 0 PEACEFUL
mc3_3  | [2024-09-14 17:15:04:459 INFO] Content logging to console is enabled.
mc3_3  | [2024-09-14 17:15:04:629 INFO] Opening level 'worlds/Bedrock level/db'
mc3_3  | [2024-09-14 17:15:04:861 ERROR] Port [19132] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
mc3_3  | [2024-09-14 17:15:04:861 ERROR] Port [19133] may be in use by another process. Free up port and re-run program or adjust server.properties file to use alternate ports for server
mc3_3  | [2024-09-14 17:15:04:861 ERROR] Exiting program

So, this makes me think it has something to do with my docker setup and perhaps not the executable, and also not docker-minecraft-bedrock-server.

What could prevent that binary from attaching to a port inside the container?

@josephdpurcell
Copy link
Contributor

josephdpurcell commented Sep 14, 2024

Oooo... I forgot: I also fiddled with my ipv6 config. I remembered this because reading https://bugs.mojang.com/browse/BDS-19079 I see:

karamelmar added a comment - 25/Mar/24 9:06 AM - edited

i can confirm this behavior.
installed the Minecraft Bedrock server on Arch server, also with IPv6 disabled via sysctl and grub, got the exact same port errors (while these ports are not used by any other proc).

Also tried a Linux Mint, and one Ubuntu 22.04 LTS with disabled IPv6, withe the same results.
Even running the Docker image of the Server on one of those machines results in the same error.

After i re-enabled IPv6, the server was starting without ant issues on all machines.

I had disabled ipv6 following https://askubuntu.com/a/337736 but then just today I re-enabled ipv6 because I was having other issues.

Well, I re-disabled ipv6 and get the same error. I am at another roadblock.

@josephdpurcell
Copy link
Contributor

I got my wires crossed. You NEED ipv6 ENABLED.

After enabling IPV6 again (and I had to very carefully re-read the instructions from the askubuntu article) it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants