Skip to content

Commit 41d7880

Browse files
committed
Add Oracle Linux image variants
The primary benefits of this are arm64 support (in 8.0) and smaller images (in 5.7 and 8.0). ```console $ docker images mysql REPO TAG IMAGE-ID SIZE mysql 5.6-debian 9e4a20b3bbbc 302MB mysql 5.6-oracle 929e36226e5f 347MB mysql 5.7-debian a4fdfd462add 448MB mysql 5.7-oracle 526647feecfa 338MB mysql 8.0-debian 30f937e841c8 541MB mysql 8.0-oracle 71ceccbba717 381MB ```
1 parent 8e67355 commit 41d7880

10 files changed

+528
-47
lines changed

.template/Dockerfile.oracle

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
FROM oraclelinux:PLACEHOLDER-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# 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
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR placeholder
45+
ENV MYSQL_VERSION placeholder
46+
# bashbrew-architectures: placeholder
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
# the "log-error" value in the MySQL 5.6 packages is set to a file (instead of being empty)
62+
sed -i '/^log-error=/d' /etc/my.cnf; \
63+
# the "socket" value in the Oracle packages is set to "/var/lib/mysql" which isn't a great place for the socket (we want it in "/var/run/mysqld" instead)
64+
# https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
65+
grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \
66+
sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \
67+
grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \
68+
\
69+
mysqld --version; \
70+
mysql --version
71+
72+
ENV MYSQL_SHELL_VERSION placeholder
73+
RUN set -eu; \
74+
. /etc/os-release; \
75+
{ \
76+
echo '[mysql-tools-community]'; \
77+
echo 'name=MySQL Tools Community'; \
78+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
79+
echo 'enabled=1'; \
80+
echo 'gpgcheck=1'; \
81+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
82+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
83+
RUN set -eux; \
84+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
85+
yum clean all; \
86+
\
87+
mysqlsh --version
88+
89+
VOLUME /var/lib/mysql
90+
COPY docker-entrypoint.sh /usr/local/bin/
91+
ENTRYPOINT ["docker-entrypoint.sh"]
92+
93+
EXPOSE 3306 33060
94+
CMD ["mysqld"]
File renamed without changes.

5.6/Dockerfile.oracle

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# 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
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 5.6
45+
ENV MYSQL_VERSION 5.6.49-2.el7
46+
# bashbrew-architectures: amd64
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
# the "log-error" value in the MySQL 5.6 packages is set to a file (instead of being empty)
62+
sed -i '/^log-error=/d' /etc/my.cnf; \
63+
# the "socket" value in the Oracle packages is set to "/var/lib/mysql" which isn't a great place for the socket (we want it in "/var/run/mysqld" instead)
64+
# https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
65+
grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \
66+
sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \
67+
grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \
68+
\
69+
mysqld --version; \
70+
mysql --version
71+
72+
ENV MYSQL_SHELL_VERSION 8.0.21-1.el7
73+
RUN set -eu; \
74+
. /etc/os-release; \
75+
{ \
76+
echo '[mysql-tools-community]'; \
77+
echo 'name=MySQL Tools Community'; \
78+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
79+
echo 'enabled=1'; \
80+
echo 'gpgcheck=1'; \
81+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
82+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
83+
RUN set -eux; \
84+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
85+
yum clean all; \
86+
\
87+
mysqlsh --version
88+
89+
VOLUME /var/lib/mysql
90+
COPY docker-entrypoint.sh /usr/local/bin/
91+
ENTRYPOINT ["docker-entrypoint.sh"]
92+
93+
EXPOSE 3306 33060
94+
CMD ["mysqld"]
File renamed without changes.

5.7/Dockerfile.oracle

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# 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
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 5.7
45+
ENV MYSQL_VERSION 5.7.31-1.el7
46+
# bashbrew-architectures: amd64
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
# the "socket" value in the Oracle packages is set to "/var/lib/mysql" which isn't a great place for the socket (we want it in "/var/run/mysqld" instead)
62+
# https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
63+
grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \
64+
sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \
65+
grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \
66+
\
67+
mysqld --version; \
68+
mysql --version
69+
70+
ENV MYSQL_SHELL_VERSION 8.0.21-1.el7
71+
RUN set -eu; \
72+
. /etc/os-release; \
73+
{ \
74+
echo '[mysql-tools-community]'; \
75+
echo 'name=MySQL Tools Community'; \
76+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
77+
echo 'enabled=1'; \
78+
echo 'gpgcheck=1'; \
79+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
80+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
81+
RUN set -eux; \
82+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
83+
yum clean all; \
84+
\
85+
mysqlsh --version
86+
87+
VOLUME /var/lib/mysql
88+
COPY docker-entrypoint.sh /usr/local/bin/
89+
ENTRYPOINT ["docker-entrypoint.sh"]
90+
91+
EXPOSE 3306 33060
92+
CMD ["mysqld"]
File renamed without changes.

8.0/Dockerfile.oracle

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# 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
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 8.0
45+
ENV MYSQL_VERSION 8.0.21-1.el7
46+
# bashbrew-architectures: amd64 arm64v8
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
# the "socket" value in the Oracle packages is set to "/var/lib/mysql" which isn't a great place for the socket (we want it in "/var/run/mysqld" instead)
62+
# https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
63+
grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my.cnf; \
64+
sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my.cnf; \
65+
grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my.cnf; \
66+
\
67+
mysqld --version; \
68+
mysql --version
69+
70+
ENV MYSQL_SHELL_VERSION 8.0.21-1.el7
71+
RUN set -eu; \
72+
. /etc/os-release; \
73+
{ \
74+
echo '[mysql-tools-community]'; \
75+
echo 'name=MySQL Tools Community'; \
76+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
77+
echo 'enabled=1'; \
78+
echo 'gpgcheck=1'; \
79+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
80+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
81+
RUN set -eux; \
82+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
83+
yum clean all; \
84+
\
85+
mysqlsh --version
86+
87+
VOLUME /var/lib/mysql
88+
COPY docker-entrypoint.sh /usr/local/bin/
89+
ENTRYPOINT ["docker-entrypoint.sh"]
90+
91+
EXPOSE 3306 33060
92+
CMD ["mysqld"]

0 commit comments

Comments
 (0)