1. 获取构建mysql镜像的脚本
git clone https://github.com/docker-library/mysql.git
2.预先下载gosu-arm64、gosu-arm64.asc ,并放到mysql/8.0目录下
wget -c https://github.com/tianon/gosu/releases/download/1.14/gosu-arm64
wget -c https://github.com/tianon/gosu/releases/download/1.14/gosu-arm64.asc
3.修改Dockerfile.oracle,使用本地下载的gosu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" # # PLEASE DO NOT EDIT IT DIRECTLY. # 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 # add gosu for easy step-down from root # https://github.com/tianon/gosu/releases ENV GOSU_VERSION 1.14 COPY . /gosu-arm64 /usr/local/bin/gosu COPY . /gosu-arm64 .asc /usr/local/bin/gosu .asc RUN set -eux; \ # TODO find a better userspace architecture detection method than querying the kernel arch= "$(uname -m)" ; \ case "$arch" in \ aarch64) gosuArch= 'arm64' ;; \ x86_64) gosuArch= 'amd64' ;; \ *) echo >&2 "error: unsupported architecture: '$arch'" ; exit 1 ;; \ esac; \ # curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \ # curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \ export GNUPGHOME= "$(mktemp -d)" ; \ gpg --batch --keyserver hkps: //keys .openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ # gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ rm -rf "$GNUPGHOME" /usr/local/bin/gosu .asc; \ chmod +x /usr/local/bin/gosu ; \ gosu --version; \ gosu nobody true RUN set -eux; \ microdnf install -y \ gzip \ openssl \ xz \ zstd \ # Oracle Linux 8+ is very slim :) findutils \ ; \ microdnf clean all RUN set -eux; \ # https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html # gpg: key 3A79BD29: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported key= '859BE8D7C586F538430B19C2467B942D3A79BD29' ; \ export GNUPGHOME= "$(mktemp -d)" ; \ gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \ gpg --batch -- export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ; \ rm -rf "$GNUPGHOME" ENV MYSQL_MAJOR 8.0 ENV MYSQL_VERSION 8.0.28-1.el8 RUN set -eu; \ . /etc/os-release ; \ { \ echo '[mysql8.0-server-minimal]' ; \ echo 'name=MySQL 8.0 Server Minimal' ; \ echo 'enabled=1' ; \ echo "baseurl=https://repo.mysql.com/yum/mysql-8.0-community/docker/el/${VERSION_ID%%[.-]*}/\$basearch/" ; \ echo 'gpgcheck=1' ; \ echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql' ; \ # https://github.com/docker-library/mysql/pull/680#issuecomment-825930524 echo 'module_hotfixes=true' ; \ } | tee /etc/yum .repos.d /mysql-community-minimal .repo RUN set -eux; \ microdnf install -y "mysql-community-server-minimal-$MYSQL_VERSION" ; \ microdnf clean all; \ # 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) # https://github.com/docker-library/mysql/pull/680#issuecomment-636121520 grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my .cnf; \ sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my .cnf; \ grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my .cnf; \ { echo '[client]' ; echo 'socket=/var/run/mysqld/mysqld.sock' ; } >> /etc/my .cnf; \ \ # make sure users dumping files in "/etc/mysql/conf.d" still works ! grep -F '!includedir' /etc/my .cnf; \ { echo ; echo '!includedir /etc/mysql/conf.d/' ; } >> /etc/my .cnf; \ mkdir -p /etc/mysql/conf .d; \ \ mysqld --version; \ mysql --version RUN set -eu; \ . /etc/os-release ; \ { \ echo '[mysql-tools-community]' ; \ echo 'name=MySQL Tools Community' ; \ echo "baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/" ; \ echo 'enabled=1' ; \ echo 'gpgcheck=1' ; \ echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql' ; \ # https://github.com/docker-library/mysql/pull/680#issuecomment-825930524 echo 'module_hotfixes=true' ; \ } | tee /etc/yum .repos.d /mysql-community-tools .repo ENV MYSQL_SHELL_VERSION 8.0.28-1.el8 RUN set -eux; \ microdnf install -y "mysql-shell-$MYSQL_SHELL_VERSION" ; \ microdnf clean all; \ \ mysqlsh --version VOLUME /var/lib/mysql COPY docker-entrypoint.sh /usr/local/bin/ ENTRYPOINT [ "docker-entrypoint.sh" ] EXPOSE 3306 33060 CMD [ "mysqld" ] |
4.执行构建Docker镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
[uos@localhost 8.0]$ docker build -f . /Dockerfile .oracle -t arm64uos /oracle-mysql :8.0 . Sending build context to Docker daemon 2.265MB Step 1 /20 : FROM oraclelinux:8-slim 8-slim: Pulling from library /oraclelinux 293fbd461d2c: Pull complete Digest: sha256:d36eb5962270036295bc6c9409a191abe8d9683be5641d20d124df52c5abb587 Status: Downloaded newer image for oraclelinux:8-slim ---> 7f0650a84bb9 Step 2 /20 : 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 ; chmod 1777 /var/lib/mysql /var/run/mysqld ; mkdir /docker-entrypoint-initdb .d ---> Running in a96e89974f96 + 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 + chmod 1777 /var/lib/mysql /var/run/mysqld + mkdir /docker-entrypoint-initdb .d Removing intermediate container a96e89974f96 ---> aaaa3a268e6a Step 3 /20 : ENV GOSU_VERSION 1.14 ---> Running in dee510f38ad9 Removing intermediate container dee510f38ad9 ---> 61b74ea8e658 Step 4 /20 : COPY . /gosu-arm64 /usr/local/bin/gosu ---> f573051a6ef2 Step 5 /20 : COPY . /gosu-arm64 .asc /usr/local/bin/gosu .asc ---> 14a1cd823dc6 Step 6 /20 : RUN set -eux; arch= "$(uname -m)" ; case "$arch" in aarch64) gosuArch= 'arm64' ;; x86_64) gosuArch= 'amd64' ;; *) echo >&2 "error: unsupported architecture: '$arch'" ; exit 1 ;; esac; export GNUPGHOME= "$(mktemp -d)" ; gpg --batch --keyserver hkps: //keys .openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; rm -rf "$GNUPGHOME" /usr/local/bin/gosu .asc; chmod +x /usr/local/bin/gosu ; gosu --version; gosu nobody true ---> Running in 7a2def91005f ++ uname -m + arch=aarch64 + case "$arch" in + gosuArch=arm64 ++ mktemp -d + export GNUPGHOME= /tmp/tmp .C3hcKppY6K + GNUPGHOME= /tmp/tmp .C3hcKppY6K + gpg --batch --keyserver hkps: //keys .openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 gpg: keybox '/tmp/tmp.C3hcKppY6K/pubring.kbx' created gpg: /tmp/tmp .C3hcKppY6K /trustdb .gpg: trustdb created gpg: key 036A9C25BF357DD4: public key "Tianon Gravi <tianon@tianon.xyz>" imported gpg: Total number processed: 1 gpg: imported: 1 + rm -rf /tmp/tmp .C3hcKppY6K /usr/local/bin/gosu .asc + chmod +x /usr/local/bin/gosu + gosu --version 1.14 (go1.16.7 on linux /arm64 ; gc) + gosu nobody true Removing intermediate container 7a2def91005f ---> 497704b804d2 Step 7 /20 : RUN set -eux; microdnf install -y gzip openssl xz zstd findutils ; microdnf clean all ---> Running in 05b43fc314d9 + microdnf install -y gzip openssl xz zstd findutils Downloading metadata... Package Repository Size Installing: findutils-1:4.6.0-20.el8.aarch64 ol8_baseos_latest 537.4 kB gzip -1.9-12.el8.aarch64 ol8_baseos_latest 168.3 kB openssl-1:1.1.1k-6.el8_5.aarch64 ol8_baseos_latest 706.2 kB xz-5.2.4-3.el8.aarch64 ol8_baseos_latest 156.1 kB zstd-1.4.4-1.0.1.el8.aarch64 ol8_appstream 310.0 kB Transaction Summary: Installing: 5 packages Reinstalling: 0 packages Upgrading: 0 packages Obsoleting: 0 packages Removing: 0 packages Downgrading: 0 packages Downloading packages... Running transaction test ... Installing: zstd;1.4.4-1.0.1.el8;aarch64;ol8_appstream Installing: xz;5.2.4-3.el8;aarch64;ol8_baseos_latest Installing: openssl;1:1.1.1k-6.el8_5;aarch64;ol8_baseos_latest Installing: gzip ;1.9-12.el8;aarch64;ol8_baseos_latest Installing: findutils;1:4.6.0-20.el8;aarch64;ol8_baseos_latest Complete. + microdnf clean all Removing intermediate container 05b43fc314d9 ---> 198bc6b97443 Step 8 /20 : RUN set -eux; key= '859BE8D7C586F538430B19C2467B942D3A79BD29' ; export GNUPGHOME= "$(mktemp -d)" ; gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; gpg --batch -- export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ; rm -rf "$GNUPGHOME" ---> Running in e0272592ac40 + key=859BE8D7C586F538430B19C2467B942D3A79BD29 + export GNUPGHOME= /tmp/tmp .de2UOzFBxB + GNUPGHOME= /tmp/tmp .de2UOzFBxB + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 859BE8D7C586F538430B19C2467B942D3A79BD29 gpg: keybox '/tmp/tmp.de2UOzFBxB/pubring.kbx' created gpg: /tmp/tmp .de2UOzFBxB /trustdb .gpg: trustdb created gpg: key 467B942D3A79BD29: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported gpg: imported: 1 + gpg --batch -- export --armor 859BE8D7C586F538430B19C2467B942D3A79BD29 + rm -rf /tmp/tmp .de2UOzFBxB Removing intermediate container e0272592ac40 ---> 3bf34d537ce4 Step 9 /20 : ENV MYSQL_MAJOR 8.0 ---> Running in f74c1276a825 Removing intermediate container f74c1276a825 ---> 71115750eae1 Step 10 /20 : ENV MYSQL_VERSION 8.0.28-1.el8 ---> Running in add5007830f4 Removing intermediate container add5007830f4 ---> 329e98f9e6ea Step 11 /20 : RUN set -eu; . /etc/os-release ; { echo '[mysql8.0-server-minimal]' ; echo 'name=MySQL 8.0 Server Minimal' ; echo 'enabled=1' ; echo "baseurl=https://repo.mysql.com/yum/mysql-8.0-community/docker/el/${VERSION_ID%%[.-]*}/\$basearch/" ; echo 'gpgcheck=1' ; echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql' ; echo 'module_hotfixes=true' ; } | tee /etc/yum .repos.d /mysql-community-minimal .repo ---> Running in 098701a53769 [mysql8.0-server-minimal] name=MySQL 8.0 Server Minimal enabled=1 baseurl=https: //repo .mysql.com /yum/mysql-8 .0-community /docker/el/8/ $basearch/ gpgcheck=1 gpgkey= file : ///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql module_hotfixes= true Removing intermediate container 098701a53769 ---> 81e9656252a7 Step 12 /20 : RUN set -eux; microdnf install -y "mysql-community-server-minimal-$MYSQL_VERSION" ; microdnf clean all; grep -F 'socket=/var/lib/mysql/mysql.sock' /etc/my .cnf; sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my .cnf; grep -F 'socket=/var/run/mysqld/mysqld.sock' /etc/my .cnf; { echo '[client]' ; echo 'socket=/var/run/mysqld/mysqld.sock' ; } >> /etc/my .cnf; ! grep -F '!includedir' /etc/my .cnf; { echo ; echo '!includedir /etc/mysql/conf.d/' ; } >> /etc/my .cnf; mkdir -p /etc/mysql/conf .d; mysqld --version; mysql --version ---> Running in 5024aade5e13 + microdnf install -y mysql-community-server-minimal-8.0.28-1.el8 Downloading metadata... Package Repository Size Installing: libaio-0.3.112-1.el8.aarch64 ol8_baseos_latest 33.2 kB libtirpc-1.1.4-5.0.1.el8.aarch64 ol8_baseos_latest 111.5 kB mysql-community-server-minimal-8.0.28-1.el8.aarch64 mysql8.0-server-minimal 33.3 MB Transaction Summary: Installing: 3 packages Reinstalling: 0 packages Upgrading: 0 packages Obsoleting: 0 packages Removing: 0 packages Downgrading: 0 packages Downloading packages... Running transaction test ... Installing: libtirpc;1.1.4-5.0.1.el8;aarch64;ol8_baseos_latest Installing: libaio;0.3.112-1.el8;aarch64;ol8_baseos_latest Installing: mysql-community-server-minimal;8.0.28-1.el8;aarch64;mysql8.0-server-minimal Complete. + microdnf clean all + grep -F socket= /var/lib/mysql/mysql .sock /etc/my .cnf socket= /var/lib/mysql/mysql .sock + sed -i 's!^socket=.*!socket=/var/run/mysqld/mysqld.sock!' /etc/my .cnf + grep -F socket= /var/run/mysqld/mysqld .sock /etc/my .cnf socket= /var/run/mysqld/mysqld .sock + echo '[client]' + echo socket= /var/run/mysqld/mysqld .sock + grep -F '!includedir' /etc/my .cnf + echo + echo '!includedir /etc/mysql/conf.d/' + mkdir -p /etc/mysql/conf .d + mysqld --version /usr/sbin/mysqld Ver 8.0.28 for Linux on aarch64 (MySQL Community Server - GPL) + mysql --version mysql Ver 8.0.28 for Linux on aarch64 (MySQL Community Server - GPL) Removing intermediate container 5024aade5e13 ---> 75d6d11a0d4f Step 13 /20 : RUN set -eu; . /etc/os-release ; { echo '[mysql-tools-community]' ; echo 'name=MySQL Tools Community' ; echo "baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/" ; echo 'enabled=1' ; echo 'gpgcheck=1' ; echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql' ; echo 'module_hotfixes=true' ; } | tee /etc/yum .repos.d /mysql-community-tools .repo ---> Running in 370f3e954c65 [mysql-tools-community] name=MySQL Tools Community baseurl=https: //repo .mysql.com /yum/mysql-tools-community/el/8/ $basearch/ module_hotfixes= true Removing intermediate container 370f3e954c65 ---> 930aadf4bd26 Step 14 /20 : ENV MYSQL_SHELL_VERSION 8.0.28-1.el8 ---> Running in 12cb073265f5 Removing intermediate container 12cb073265f5 ---> 146a70d69280 Step 15 /20 : RUN set -eux; microdnf install -y "mysql-shell-$MYSQL_SHELL_VERSION" ; microdnf clean all; mysqlsh --version ---> Running in ded458b7a5c5 + microdnf install -y mysql-shell-8.0.28-1.el8 Package Repository Size Installing: expat-2.2.5-4.0.1.el8_5.3.aarch64 ol8_baseos_latest 105.8 kB gdbm-libs-1:1.18-1.el8.aarch64 ol8_baseos_latest 60.5 kB libnsl2-1.2.0-2.20180605git4a062cf.el8.aarch64 ol8_baseos_latest 56.4 kB mysql-shell-8.0.28-1.el8.aarch64 mysql-tools-community 18.6 MB python39-libs-3.9.6-2.module+el8.5.0+20364+c7fe1181.aarch64 ol8_appstream 8.4 MB python39-pip-wheel-20.2.4-6.module+el8.5.0+20364+c7fe1181.noarch ol8_appstream 1.3 MB python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch ol8_appstream 508.6 kB Installing: 7 packages Enabling module streams: python39:3.9 Installing: python39-setuptools-wheel;50.3.2-4.module+el8.5.0+20364+c7fe1181;noarch;ol8_appstream Installing: python39-pip-wheel;20.2.4-6.module+el8.5.0+20364+c7fe1181;noarch;ol8_appstream Installing: libnsl2;1.2.0-2.20180605git4a062cf.el8;aarch64;ol8_baseos_latest Installing: gdbm-libs;1:1.18-1.el8;aarch64;ol8_baseos_latest Installing: expat;2.2.5-4.0.1.el8_5.3;aarch64;ol8_baseos_latest Installing: python39-libs;3.9.6-2.module+el8.5.0+20364+c7fe1181;aarch64;ol8_appstream Installing: mysql-shell;8.0.28-1.el8;aarch64;mysql-tools-community + mysqlsh --version Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory mysqlsh Ver 8.0.28 for Linux on aarch64 - for MySQL 8.0.28 (MySQL Community Server (GPL)) Removing intermediate container ded458b7a5c5 ---> 242cc65de9a1 Step 16 /20 : VOLUME /var/lib/mysql ---> Running in 5cc99dcada97 Removing intermediate container 5cc99dcada97 ---> fd89b8c734f5 Step 17 /20 : COPY docker-entrypoint.sh /usr/local/bin/ ---> 2793d27294e2 Step 18 /20 : ENTRYPOINT [ "docker-entrypoint.sh" ] ---> Running in 057accf923c3 Removing intermediate container 057accf923c3 ---> 39b58c0645c2 Step 19 /20 : EXPOSE 3306 33060 ---> Running in e08e5b46adfc Removing intermediate container e08e5b46adfc ---> eed18bbc8cbd Step 20 /20 : CMD [ "mysqld" ] ---> Running in a356b9dc7916 Removing intermediate container a356b9dc7916 ---> df723596f0a2 Successfully built df723596f0a2 Successfully tagged arm64uos /oracle-mysql :8.0 |
到此这篇关于构建aarch64环境Mysql8.0的Docker镜像的文章就介绍到这了,更多相关Mysql Docker镜像内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://www.cnblogs.com/ecom/p/16158072.html