Skip to content

Instantly share code, notes, and snippets.

@akunzai
Created September 9, 2024 16:04
Show Gist options
  • Save akunzai/5f0064f530a014a742f327a20bc77f8c to your computer and use it in GitHub Desktop.
Save akunzai/5f0064f530a014a742f327a20bc77f8c to your computer and use it in GitHub Desktop.
Nginx container modify UID or GID
#!/bin/sh
USERID=$(id -u)
if [ "${USERID}" = "0" ] && [ -n "${NGINX_UID}" ] && [ "${NGINX_UID}" != "0" ]; then
usermod -u "${NGINX_UID}" nginx
if [ -n "${NGINX_GID}" ] && [ "${NGINX_GID}" != "0" ]; then
groupmod -g "${NGINX_GID}" nginx
fi
# Ensure the nginx user is able to write to container logs
chown nginx:nginx /dev/stdout /dev/stderr
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment