Created
September 9, 2024 16:04
-
-
Save akunzai/5f0064f530a014a742f327a20bc77f8c to your computer and use it in GitHub Desktop.
Nginx container modify UID or GID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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