Skip to content
17 changes: 13 additions & 4 deletions 5.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ RUN set -ex; \
# gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
for keyserver in $(shuf -e \
ha.pool.sks-keyservers.net \
hkp://p80.pool.sks-keyservers.net:80 \
keyserver.ubuntu.com \
hkp://keyserver.ubuntu.com:80 \
pgp.mit.edu) ; do \
gpg --keyserver $keyserver --recv-keys "$key" && break || true ; \
done && \
gpg --export "$key" > /etc/apt/trusted.gpg.d/mysql.gpg; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME"; \
Expand Down Expand Up @@ -72,9 +79,11 @@ RUN { \

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
WORKDIR /usr/local/bin
COPY ./docker-entrypoint.sh .
RUN chmod 0755 ./docker-entrypoint.sh
RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
ENTRYPOINT ["./docker-entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]
13 changes: 8 additions & 5 deletions 5.7/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ _get_config() {
if [ "$1" = 'mysqld' -a -z "$wantHelp" -a "$(id -u)" = '0' ]; then
_check_config "$@"
DATADIR="$(_get_config 'datadir' "$@")"
mkdir -p "$DATADIR"
chown -R mysql:mysql "$DATADIR"
# seed scripts from a copy of the initdb.d dir because EID mysql may not have permission to read
# a docker volume mounted on the usual initdb.d path
mkdir -p "$DATADIR" /etc/mysql/initdb.d/
cp -RT /docker-entrypoint-initdb.d /etc/mysql/initdb.d
chown -R mysql:mysql "$DATADIR" /etc/mysql/initdb.d/
exec gosu mysql "$BASH_SOURCE" "$@"
fi

Expand All @@ -95,7 +98,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
# Get config
DATADIR="$(_get_config 'datadir' "$@")"

if [ ! -d "$DATADIR/mysql" ]; then
if [ ! -d "${DATADIR%/}/mysql" ]; then
file_env 'MYSQL_ROOT_PASSWORD'
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
echo >&2 'error: database is uninitialized and password option is not specified '
Expand Down Expand Up @@ -191,8 +194,8 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
fi

echo
ls /docker-entrypoint-initdb.d/ > /dev/null
for f in /docker-entrypoint-initdb.d/*; do
ls /etc/mysql/initdb.d/ > /dev/null
for f in /etc/mysql/initdb.d/*; do
process_init_file "$f" "${mysql[@]}"
done

Expand Down