Sfoglia il codice sorgente

Merge pull request #1353 from zauberzeug/entrypoint

prevent errors if non-root user already exists
Falko Schindler 1 anno fa
parent
commit
09336bfc57
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      docker-entrypoint.sh

+ 4 - 2
docker-entrypoint.sh

@@ -15,8 +15,10 @@ fi
 if ! getent group "$PGID" >/dev/null; then
 if ! getent group "$PGID" >/dev/null; then
   groupadd -g "$PGID" appgroup
   groupadd -g "$PGID" appgroup
 fi
 fi
-# Create user.
-useradd --create-home --shell /bin/bash --uid "$PUID" --gid "$PGID" appuser
+# Create user if it doesn't exist.
+if ! getent passwd "$PUID" >/dev/null; then
+  useradd --create-home --shell /bin/bash --uid "$PUID" --gid "$PGID" appuser
+fi
 # Make user the owner of the app directory.
 # Make user the owner of the app directory.
 chown -R appuser:appgroup /app
 chown -R appuser:appgroup /app
 # Copy the default .bashrc file to the appuser home directory.
 # Copy the default .bashrc file to the appuser home directory.