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

Start up file permission denied #2510

Closed
TheAceMan opened this issue Nov 25, 2023 · 5 comments · Fixed by #2511
Closed

Start up file permission denied #2510

TheAceMan opened this issue Nov 25, 2023 · 5 comments · Fixed by #2511

Comments

@TheAceMan
Copy link

TheAceMan commented Nov 25, 2023

Describe the problem

I have a few minecraft servers running in Docker for a while but recently ran into a startup issue. This is the error I receive:

[init] Running as uid=1000 gid=1000 with /data as 'drwxr-xr-x. 2 1000 1000 0 Nov 25 19:31 /data'
/start-configuration: line 87: /data/.rcon-cli.env: Permission denied

I recently updated the the docker server packages and restarted the server when I think the issues begin. Not sure if it pulled a newer image as part of that or not.

A new server with this same docker compose will start fine using an empty directly and can write files but if I restart the new server it fails with the above error. Appears it can not modify the existing file for some reason at start up. I assume it is something to do with using a volume mount but it had been working until recently. Any direction would be helpful as I have tried multiple changes to the file share and the container security/user values.

Also I moved a new minecraft server to Kubernetes and see the same issue, a new instance of minecraft starts correctly but if I delete the pod it will have the same error when creating the new pod using the existing files on the fileshare. This is using the same file share. So think it is either the file share or container having an issue but can't put my finger on what is going on.

Container definition

version: "3.9"
services:
  mc-survival:
    container_name: mc-survival
    image: itzg/minecraft-server
    restart: unless-stopped
    networks:
      - minecraft
    security_opt:
      - no-new-privileges:true
    volumes:
      - minecraft_data_survival:/data
    environment:
      - MOTD="survival world"
      - EULA=TRUE
      - DIFFICULTY=easy
      - MODE=survival
      - LEVEL_TYPE=default
      - MAX_TICK_TIME="-1"
      - MEMORY=3G

volumes:
  minecraft_data_survival:
    driver_opts:
      o: "username=user,password=pass,uid=1000,gid=1000"
      type: "cifs"
      device: \\192.168.1.22\minecraft\data\survival

Container logs

[init] Running as uid=1000 gid=1000 with /data as 'drwxr-xr-x. 2 1000 1000 0 Nov 25 19:31 /data'
/start-configuration: line 87: /data/.rcon-cli.env: Permission denied
@itzg
Copy link
Owner

itzg commented Nov 26, 2023

I'm guessing it's because that file gets written as root user during initial container startup. I'll have it remove pre-existing file as root, but write it just a little bit later as regular user (uid=1000).

@itzg
Copy link
Owner

itzg commented Nov 26, 2023

When this build finishes, please see if pulling that image resolves your issue. If it doesn't, you can re-open this and provide any new errors/issues it reports.

@TheAceMan
Copy link
Author

TheAceMan commented Nov 26, 2023

Getting the same error, new line number:

[init] Running as uid=1000 gid=1000 with /data as 'drwxrwxrwx 2 1000 1000 0 Nov 23 11:50 /data'
/start-configuration: line 74: /data/.rcon-cli.env: Permission denied

Don't see a way to re-open the issue.

If I delete the .rcon-cli.env file the server gets a bit further, I see the file is recreated as well. This is a different server from the compose I posted earlier. And forge is installed but re-installs it because I am assuming it can't read the file. The file /data/.forge-manifest.json already exists and was created by the first run of the server.

[init] Running as uid=1000 gid=1000 with /data as 'drwxrwxrwx 2 1000 1000 0 Nov 25 23:07 /data'
[init] Resolving type given FORGE
[mc-image-helper] 23:07:49.307 INFO  : Re-installing Forge due to version change from MC 1.20.1/Forge 47.2.0 to MC 1.20.1/Forge 47.2.6
[mc-image-helper] 23:07:49.309 INFO  : Downloading Forge installer 47.2.6 for Minecraft 1.20.1
[mc-image-helper] 23:07:49.941 INFO  : Running Forge installer. This might take a while...
[mc-image-helper] 23:10:38.329 ERROR : 'install-forge' command failed. Version is 1.37.0
me.itzg.helpers.files.ManifestException: Failed to save manifest
	at me.itzg.helpers.files.Manifests.save(Manifests.java:153)
	at me.itzg.helpers.forge.ForgeInstaller.install(ForgeInstaller.java:95)
	at me.itzg.helpers.forge.InstallForgeCommand.call(InstallForgeCommand.java:103)
	at me.itzg.helpers.forge.InstallForgeCommand.call(InstallForgeCommand.java:19)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
	at picocli.CommandLine.execute(CommandLine.java:2170)
	at me.itzg.helpers.McImageHelper.main(McImageHelper.java:157)
Caused by: java.io.FileNotFoundException: /data/.forge-manifest.json (Permission denied)
	at java.base/java.io.FileOutputStream.open0(Native Method)
	at java.base/java.io.FileOutputStream.open(Unknown Source)
	at java.base/java.io.FileOutputStream.<init>(Unknown Source)
	at java.base/java.io.FileOutputStream.<init>(Unknown Source)
	at com.fasterxml.jackson.core.TokenStreamFactory._fileOutputStream(TokenStreamFactory.java:334)
	at com.fasterxml.jackson.core.JsonFactory.createGenerator(JsonFactory.java:1547)
	at com.fasterxml.jackson.databind.ObjectMapper.createGenerator(ObjectMapper.java:1257)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3980)
	at me.itzg.helpers.files.Manifests.save(Manifests.java:150)
	... 12 common frames omitted
[init] ERROR failed to install Forge

@itzg itzg reopened this Nov 26, 2023
@github-project-automation github-project-automation bot moved this from Done to In progress in Docker Minecraft Nov 26, 2023
@itzg
Copy link
Owner

itzg commented Nov 26, 2023

I'll re-open for discussion sake, but there's some various file ownership mismatches going on with your setup. Since you're using CIFS, then that'll beyond the typical things I can offer to debug.

@itzg itzg added discussion and removed bug labels Nov 26, 2023
@itzg itzg removed this from Docker Minecraft Nov 28, 2023
@TheAceMan
Copy link
Author

After further testing in the container, I determined it was something specific to dotfiles when I was in the container:

Could create a new dotfile but would not allow overwriting.

minecraft@mc-testserver-minecraft-0:~$ echo "password=${RCON_PASSWORD}" > "$HOME/.rcon-cli2.env"
minecraft@mc-testserver-minecraft-0:~$ echo "password=${RCON_PASSWORD}" > "$HOME/.rcon-cli2.env"
bash: /data/.rcon-cli2.env: Permission denied

Standard (non-dotfile) files I could create and overwrite:

minecraft@mc-testserver-minecraft-0:~$ echo "password=${RCON_PASSWORD}" > "$HOME/rcon-cli2.env"
minecraft@mc-testserver-minecraft-0:~$ echo "password=${RCON_PASSWORD}" > "$HOME/rcon-cli2.env"

Fixed this by updating my smb share to hide dot files = no and things appear to be working. Haven't had a chance to look deep into this and may be unrelated since I recreated the share as part of this.

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

Successfully merging a pull request may close this issue.

2 participants