From 70a55e3be1e879ecee90f8a580f20c5dbbf22937 Mon Sep 17 00:00:00 2001 From: Piero Steinger Date: Fri, 29 Jan 2016 20:50:53 +0100 Subject: [PATCH] [minecraft] Pass GID as docker option --- minecraft-server/Dockerfile | 2 +- minecraft-server/README.md | 13 +++++++------ minecraft-server/start-minecraft.sh | 2 ++ minecraft-server/start.sh | 5 ++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index d30a6ebb..1ad07ab6 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -34,7 +34,7 @@ CMD [ "/start" ] # Special marker ENV used by MCCY management tool ENV MC_IMAGE=YES -ENV UID=1000 +ENV UID=1000 GID=1000 ENV MOTD A Minecraft Server Powered by Docker ENV JVM_OPTS -Xmx1024M -Xms1024M ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \ diff --git a/minecraft-server/README.md b/minecraft-server/README.md index ef671b4c..59d66d49 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -68,15 +68,16 @@ to map a directory on your host machine to the container's `/data` directory, su When attached in this way you can stop the server, edit the configuration under your attached `/path/on/host` and start the server again with `docker start CONTAINERID` to pick up the new configuration. -**NOTE**: By default, the files in the attached directory will be owned by the host user with UID of 1000. -You can use an different UID by passing the option: +**NOTE**: By default, the files in the attached directory will be owned by the host user with UID of 1000 and host group with GID of 1000. +You can use an different UID and GID by passing the options: - -e UID=1000 + -e UID=1000 -e GID=1000 -replacing 1000 with a UID that is present on the host. -Here is one way to find the UID given a username: +replacing 1000 with a UID and GID that is present on the host. +Here is one way to find the UID and GID: - grep some_host_user /etc/passwd|cut -d: -f3 + id some_host_user + getent group some_host_group ## Versions diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index a98238ac..face1504 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -1,5 +1,7 @@ #!/bin/bash +umask 002 + if [ ! -e /data/eula.txt ]; then if [ "$EULA" != "" ]; then echo "# Generated via Docker on $(date)" > eula.txt diff --git a/minecraft-server/start.sh b/minecraft-server/start.sh index 7d57aca1..5f91e8fb 100755 --- a/minecraft-server/start.sh +++ b/minecraft-server/start.sh @@ -2,7 +2,10 @@ set -e usermod --uid $UID minecraft -chown -R minecraft /data /start-minecraft +groupmod --gid $GID minecraft + +chown -R minecraft:minecraft /data /start-minecraft +chmod -R g+wX /data /start-minecraft while lsof -- /start-minecraft; do echo -n "."