From 41033e32e04f3d36b77aa9b2597e5c414486f06a Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Wed, 18 Oct 2017 20:58:34 +0000 Subject: [PATCH] Run image as user unifi using USER directive and not sudo --- Dockerfile | 5 ++++- run.sh | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e4262b..5c8419b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,8 @@ && rm -rf unifi_sysvinit_all.deb /var/lib/unifi/* \ && groupadd -r -g 500 unifi \ && useradd -r -d /usr/lib/unifi -u 500 -g 500 unifi \ - && chown -Rf unifi:unifi /usr/lib/unifi + && mkdir /usr/lib/unifi/data /var/lib/unifi \ + && chown -Rf unifi:unifi /usr/lib/unifi /var/lib/unifi EXPOSE 8080 8081 8443 8843 8880 @@ -24,3 +25,5 @@ WORKDIR /var/lib/unifi COPY run.sh /run.sh CMD /run.sh + +USER unifi diff --git a/run.sh b/run.sh index a04e068..f52b031 100755 --- a/run.sh +++ b/run.sh @@ -4,6 +4,10 @@ JAVA_OPTS="-Xmx1024m" fi -chown -Rf unifi:unifi /usr/lib/unifi/data +if [ `id -u` -eq 0 ]; then + chown -Rf unifi:unifi /usr/lib/unifi/data -exec sudo -u unifi java $JAVA_OPTS -jar /usr/lib/unifi/lib/ace.jar start + exec sudo -u unifi java $JAVA_OPTS -jar /usr/lib/unifi/lib/ace.jar start +else + exec java $JAVA_OPTS -jar /usr/lib/unifi/lib/ace.jar start +fi -- Gitblit v1.9.1