diff --git a/5.7/Dockerfile.oracle b/5.7/Dockerfile.oracle index 882bdb369..d173e0ff6 100644 --- a/5.7/Dockerfile.oracle +++ b/5.7/Dockerfile.oracle @@ -8,14 +8,7 @@ FROM oraclelinux:7-slim 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 @@ -93,6 +86,20 @@ RUN set -eux; \ { 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)/#&/'; \ + \ +# 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 diff --git a/8.0/Dockerfile.oracle b/8.0/Dockerfile.oracle index 4ae731bce..53edac964 100644 --- a/8.0/Dockerfile.oracle +++ b/8.0/Dockerfile.oracle @@ -8,14 +8,7 @@ FROM oraclelinux:8-slim 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 @@ -89,6 +82,14 @@ RUN set -eux; \ ! grep -F '!includedir' /etc/my.cnf; \ { echo; echo '!includedir /etc/mysql/conf.d/'; } >> /etc/my.cnf; \ mkdir -p /etc/mysql/conf.d; \ +# 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 diff --git a/template/Dockerfile.oracle b/template/Dockerfile.oracle index 2f2e0b957..e050b5722 100644 --- a/template/Dockerfile.oracle +++ b/template/Dockerfile.oracle @@ -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 @@ -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