Skip to content

Commit

Permalink
Fix arbitrary user support on oracle-linux based images
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed Jul 12, 2022
1 parent 6b30925 commit 48f07e3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
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)/#&/'; \
\
{{ ) 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

0 comments on commit 48f07e3

Please sign in to comment.