Skip to content

Fix arbitrary user support on oracle-linux based images #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions 5.7/Dockerfile.oracle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions 8.0/Dockerfile.oracle

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions template/Dockerfile.oracle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ FROM oraclelinux:{{ .oracle.variant }}

RUN set -eux; \
groupadd --system --gid 999 mysql; \
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
\
mkdir /var/lib/mysql /var/run/mysqld; \
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
chmod 1777 /var/lib/mysql /var/run/mysqld; \
\
mkdir /docker-entrypoint-initdb.d
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql

# add gosu for easy step-down from root
# https://github.com/tianon/gosu/releases
Expand Down Expand Up @@ -108,7 +101,21 @@ RUN set -eux; \
# 5.7 Debian-based images also included "/etc/mysql/mysql.conf.d" so let's include it too
{ echo '!includedir /etc/mysql/mysql.conf.d/'; } >> /etc/my.cnf; \
mkdir -p /etc/mysql/mysql.conf.d; \
\
# comment out a few problematic configuration values
find /etc/my.cnf /etc/mysql/ -name '*.cnf' -print0 \
| xargs -0 grep -lZE '^(bind-address|log)' \
| xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/'; \
Comment on lines +105 to +108
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are copied from the Debian Dockerfile even though we don't have a bind-address in the cnf file.

\
{{ ) else "" end -}}
# ensure these directories exist and have useful permissions
# the rpm package has different opinions on the mode of `/var/run/mysqld`, so this needs to be after install
mkdir -p /var/lib/mysql /var/run/mysqld; \
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
chmod 1777 /var/lib/mysql /var/run/mysqld; \
\
mkdir /docker-entrypoint-initdb.d; \
\
mysqld --version; \
mysql --version
Expand Down