From 03d9064b35d2622b28e89e451cf3b88a0f196c07 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 27 Feb 2016 17:10:11 -0600 Subject: [PATCH] [mc] Putting back usermod solution --- minecraft-server/Dockerfile | 6 +++--- minecraft-server/start.sh | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100755 minecraft-server/start.sh diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 3a5ba57a..d0c1a86c 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER itzg ENV APT_GET_UPDATE 2015-10-03 RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-24-bin imagemagick lsof && apt-get clean +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-24-bin imagemagick lsof sudo && apt-get clean RUN update-alternatives --install /usr/bin/js js /usr/bin/js24 100 RUN wget -O /usr/bin/jsawk https://github.com/micha/jsawk/raw/master/jsawk @@ -19,6 +19,7 @@ RUN useradd -M -s /bin/false --uid 1000 minecraft \ EXPOSE 25565 +COPY start.sh /start COPY start-minecraft.sh /start-minecraft VOLUME ["/data"] @@ -28,8 +29,7 @@ VOLUME ["/plugins"] COPY server.properties /tmp/server.properties WORKDIR /data -USER minecraft -CMD [ "/start-minecraft" ] +CMD [ "/start" ] # Special marker ENV used by MCCY management tool ENV MC_IMAGE=YES diff --git a/minecraft-server/start.sh b/minecraft-server/start.sh new file mode 100755 index 00000000..5f91e8fb --- /dev/null +++ b/minecraft-server/start.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e +usermod --uid $UID 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 "." + sleep 1 +done +echo "...switching to user 'minecraft'" +exec sudo -E -u minecraft /start-minecraft