1. 首页
  2. 技术知识

关于构建aarch64环境Mysql8.0的Docker镜像问题

目录

    1. 获取构建mysql镜像的脚本2.预先下载gosu-arm64、gosu-arm64.asc ,并放到mysql/8.0目录下3.修改Dockerfile.oracle,使用本地下载的gosu4.执行构建Docker镜像

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. # NOTE: THIS DOCKERFILE IS GENERATED VIA “APPly-templates.sh”
  3. #
  4. # PLEASE DO NOT EDIT IT DIRECTLY.
  5. #
  6. FROM oraclelinux:8-slim
  7. RUN set -eux; \
  8.         groupadd –system –gid 999 mysql; \
  9.         useradd –system –uid 999 –gid 999 –home-dir /var/lib/mysql –no-create-home mysql; \
  10.         \
  11.         mkdir /var/lib/mysql /var/run/mysqld; \
  12.         chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
  13. # 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
  14.         chmod 1777 /var/lib/mysql /var/run/mysqld; \
  15.         \
  16.         mkdir /docker-entrypoint-initdb.d
  17. # add gosu for easy step-down from root
  18. # https://github.com/tianon/gosu/releases
  19. ENV GOSU_VERSION 1.14
  20. COPY ./gosu-arm64 /usr/local/bin/gosu
  21. COPY ./gosu-arm64.asc /usr/local/bin/gosu.asc
  22. RUN set -eux; \
  23. # TODO find a better userspace architecture detection method than querying the kernel
  24.         arch=”$(uname -m)”; \
  25.         case “$arch” in \
  26.                 aarch64) gosuArch=’arm64′ ;; \
  27.                 x86_64) gosuArch=’amd64′ ;; \
  28.                 *) echo >&2 “error: unsupported architecture: ‘$arch'”; exit 1 ;; \
  29.         esac; \
  30. #       curl -fL -o /usr/local/bin/gosu.asc “https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc”; \
  31. #       curl -fL -o /usr/local/bin/gosu “https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch”; \
  32.         export GNUPGHOME=”$(mktemp -d)”; \
  33.         gpg –batch –keyserver hkps://keys.openpgp.org –recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
  34. #       gpg –batch –verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
  35.         rm -rf “$GNUPGHOME” /usr/local/bin/gosu.asc; \
  36.         chmod +x /usr/local/bin/gosu; \
  37.         gosu –version; \
  38.         gosu nobody true
  39. RUN set -eux; \
  40.         microdnf install -y \
  41.                 gzip \
  42.                 openssl \
  43.                 xz \
  44.                 zstd \
  45. # Oracle Linux 8+ is very slim 🙂
  46.                 findutils \
  47.         ; \
  48.         microdnf clean all
  49. RUN set -eux; \
  50. # https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
  51. # gpg: key 3A79BD29: public key “MySQL Release Engineering <mysql-build@oss.oracle.com>” imported
  52.         key=’859BE8D7C586F538430B19C2467B942D3A79BD29′; \
  53.         export GNUPGHOME=”$(mktemp -d)”; \
  54.         gpg –batch –keyserver keyserver.ubuntu.com –recv-keys “$key”; \
  55.         gpg –batch –export –armor “$key” > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
  56.         rm -rf “$GNUPGHOME”
  57. ENV MYSQL_MAJOR 8.0
  58. ENV MYSQL_VERSION 8.0.28-1.el8
  59. RUN set -eu; \
  60.         . /etc/os-release; \
  61.         { \
  62.                 echo ‘[mysql8.0-server-minimal]’; \
  63.                 echo ‘name=MySQL 8.0 Server Minimal’; \
  64.                 echo ‘enabled=1’; \
  65.                 echo “baseurl=https://repo.mysql.com/yum/mysql-8.0-community/docker/el/${VERSION_ID%%[.-]*}/\$basearch/”; \
  66.                 echo ‘gpgcheck=1’; \
  67.                 echo ‘gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql’; \
  68. # https://github.com/docker-library/mysql/pull/680#issuecomment-825930524
  69.                 echo ‘module_hotfixes=true’; \
  70.         } | tee /etc/yum.repos.d/mysql-community-minimal.repo
  71. RUN set -eux; \
  72.         microdnf install -y “mysql-community-server-minimal-$MYSQL_VERSION”; \
  73.         microdnf clean all; \
  74. # 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)
  75. # https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
  76.         grep -F ‘socket=/var/lib/mysql/mysql.sock’ /etc/my.cnf; \
  77.         sed -i ‘s!^socket=.*!socket=/var/run/mysqld/mysqld.sock!’ /etc/my.cnf; \
  78.         grep -F ‘socket=/var/run/mysqld/mysqld.sock’ /etc/my.cnf; \
  79.         { echo ‘[client]’; echo ‘socket=/var/run/mysqld/mysqld.sock’; } >> /etc/my.cnf; \
  80.         \
  81. # make sure users dumping files in “/etc/mysql/conf.d” still works
  82.         ! grep -F ‘!includedir’ /etc/my.cnf; \
  83.         { echo; echo ‘!includedir /etc/mysql/conf.d/’; } >> /etc/my.cnf; \
  84.         mkdir -p /etc/mysql/conf.d; \
  85.         \
  86.         mysqld –version; \
  87.         mysql –version
  88. RUN set -eu; \
  89.         . /etc/os-release; \
  90.         { \
  91.                 echo ‘[mysql-tools-community]’; \
  92.                 echo ‘name=MySQL Tools Community’; \
  93.                 echo “baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/”; \
  94.                 echo ‘enabled=1’; \
  95.                 echo ‘gpgcheck=1’; \
  96.                 echo ‘gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql’; \
  97. # https://github.com/docker-library/mysql/pull/680#issuecomment-825930524
  98.                 echo ‘module_hotfixes=true’; \
  99.         } | tee /etc/yum.repos.d/mysql-community-tools.repo
  100. ENV MYSQL_SHELL_VERSION 8.0.28-1.el8
  101. RUN set -eux; \
  102.         microdnf install -y “mysql-shell-$MYSQL_SHELL_VERSION”; \
  103.         microdnf clean all; \
  104.         \
  105.         mysqlsh –version
  106. VOLUME /var/lib/mysql
  107. COPY docker-entrypoint.sh /usr/local/bin/
  108. ENTRYPOINT [“docker-entrypoint.sh”]
  109. EXPOSE 3306 33060
  110. CMD [“mysqld”]

复制代码
4.执行构建Docker镜像

  1. [uos@localhost 8.0]$ docker build -f ./Dockerfile.oracle -t arm64uos/oracle-mysql:8.0 .
  2.    Sending build context to Docker daemon 2.265MB
  3.    Step 1/20 : FROM oraclelinux:8-slim
  4.    8-slim: Pulling from library/oraclelinux
  5.   293fbd461d2c: Pull complete
  6.    Digest: sha256:d36eb5962270036295bc6c9409a191abe8d9683be5641d20d124df52c5abb587
  7.    Status: Downloaded newer image for oraclelinux:8-slim
  8.    —> 7f0650a84bb9
  9.    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
  10.   —> Running in a96e89974f96
  11.   + groupadd –system –gid 999 mysql
  12.   + useradd –system –uid 999 –gid 999 –home-dir /var/lib/mysql –no-create-home mysql
  13.   + mkdir /var/lib/mysql /var/run/mysqld
  14.   + chown mysql:mysql /var/lib/mysql /var/run/mysqld
  15.   + chmod 1777 /var/lib/mysql /var/run/mysqld
  16.   + mkdir /docker-entrypoint-initdb.d
  17.   Removing intermediate container a96e89974f96
  18.   —> aaaa3a268e6a
  19.   Step 3/20 : ENV GOSU_VERSION 1.14
  20.   —> Running in dee510f38ad9
  21.   Removing intermediate container dee510f38ad9
  22.   —> 61b74ea8e658
  23.   Step 4/20 : COPY ./gosu-arm64 /usr/local/bin/gosu
  24.   —> f573051a6ef2
  25.   Step 5/20 : COPY ./gosu-arm64.asc /usr/local/bin/gosu.asc
  26.   —> 14a1cd823dc6
  27.   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
  28.   —> Running in 7a2def91005f
  29.   ++ uname -m
  30.   + arch=aarch64
  31.   + case “$arch” in
  32.   + gosuArch=arm64
  33.   ++ mktemp -d
  34.   + export GNUPGHOME=/tmp/tmp.C3hcKppY6K
  35.   + GNUPGHOME=/tmp/tmp.C3hcKppY6K
  36.   + gpg –batch –keyserver hkps://keys.openpgp.org –recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
  37.   gpg: keybox ‘/tmp/tmp.C3hcKppY6K/pubring.kbx’ created
  38.   gpg: /tmp/tmp.C3hcKppY6K/trustdb.gpg: trustdb created
  39.   gpg: key 036A9C25BF357DD4: public key “Tianon Gravi <tianon@tianon.xyz>” imported
  40.   gpg: Total number processed: 1
  41.   gpg: imported: 1
  42.   + rm -rf /tmp/tmp.C3hcKppY6K /usr/local/bin/gosu.asc
  43.   + chmod +x /usr/local/bin/gosu
  44.   + gosu –version
  45.   1.14 (go1.16.7 on linux/arm64; gc)
  46.   + gosu nobody true
  47. Removing intermediate container 7a2def91005f
  48.   —> 497704b804d2
  49.   Step 7/20 : RUN set -eux; microdnf install -y gzip openssl xz zstd findutils ; microdnf clean all
  50.   —> Running in 05b43fc314d9
  51.   + microdnf install -y gzip openssl xz zstd findutils
  52.   Downloading metadata…
  53.   Package Repository Size
  54.   Installing:
  55.   findutils-1:4.6.0-20.el8.aarch64 ol8_baseos_latest 537.4 kB
  56.   gzip-1.9-12.el8.aarch64 ol8_baseos_latest 168.3 kB
  57.   openssl-1:1.1.1k-6.el8_5.aarch64 ol8_baseos_latest 706.2 kB
  58.   xz-5.2.4-3.el8.aarch64 ol8_baseos_latest 156.1 kB
  59.   zstd-1.4.4-1.0.1.el8.aarch64 ol8_appstream 310.0 kB
  60.   Transaction Summary:
  61.   Installing: 5 packages
  62.   Reinstalling: 0 packages
  63.   Upgrading: 0 packages
  64.   Obsoleting: 0 packages
  65.   Removing: 0 packages
  66.   Downgrading: 0 packages
  67.   Downloading packages…
  68.   Running transaction test…
  69.   Installing: zstd;1.4.4-1.0.1.el8;aarch64;ol8_appstream
  70.   Installing: xz;5.2.4-3.el8;aarch64;ol8_baseos_latest
  71.   Installing: openssl;1:1.1.1k-6.el8_5;aarch64;ol8_baseos_latest
  72.   Installing: gzip;1.9-12.el8;aarch64;ol8_baseos_latest
  73.   Installing: findutils;1:4.6.0-20.el8;aarch64;ol8_baseos_latest
  74.   Complete.
  75.   + microdnf clean all
  76.   Removing intermediate container 05b43fc314d9
  77.   —> 198bc6b97443
  78.   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”
  79.   —> Running in e0272592ac40
  80.   + key=859BE8D7C586F538430B19C2467B942D3A79BD29
  81.   + export GNUPGHOME=/tmp/tmp.de2UOzFBxB
  82.   + GNUPGHOME=/tmp/tmp.de2UOzFBxB
  83.   + gpg –batch –keyserver keyserver.ubuntu.com –recv-keys 859BE8D7C586F538430B19C2467B942D3A79BD29
  84.   gpg: keybox ‘/tmp/tmp.de2UOzFBxB/pubring.kbx’ created
  85. gpg: /tmp/tmp.de2UOzFBxB/trustdb.gpg: trustdb created
  86. gpg: key 467B942D3A79BD29: public key “MySQL Release Engineering <mysql-build@oss.oracle.com>” imported
  87. gpg: imported: 1
  88.   + gpg –batch –export –armor 859BE8D7C586F538430B19C2467B942D3A79BD29
  89.   + rm -rf /tmp/tmp.de2UOzFBxB
  90.   Removing intermediate container e0272592ac40
  91. —> 3bf34d537ce4
  92.   Step 9/20 : ENV MYSQL_MAJOR 8.0
  93.   —> Running in f74c1276a825
  94. Removing intermediate container f74c1276a825
  95. —> 71115750eae1
  96. Step 10/20 : ENV MYSQL_VERSION 8.0.28-1.el8
  97. —> Running in add5007830f4
  98. Removing intermediate container add5007830f4
  99. —> 329e98f9e6ea
  100. 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
  101. —> Running in 098701a53769
  102. [mysql8.0-server-minimal]
  103. name=MySQL 8.0 Server Minimal
  104. enabled=1
  105. baseurl=https://repo.mysql.com/yum/mysql-8.0-community/docker/el/8/$basearch/
  106. gpgcheck=1
  107. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  108. module_hotfixes=true
  109. Removing intermediate container 098701a53769
  110. —> 81e9656252a7
  111. 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
  112. —> Running in 5024aade5e13
  113. + microdnf install -y mysql-community-server-minimal-8.0.28-1.el8
  114. Downloading metadata…
  115. Package Repository Size
  116. Installing:
  117. libaio-0.3.112-1.el8.aarch64 ol8_baseos_latest 33.2 kB
  118. libtirpc-1.1.4-5.0.1.el8.aarch64 ol8_baseos_latest 111.5 kB
  119. mysql-community-server-minimal-8.0.28-1.el8.aarch64 mysql8.0-server-minimal 33.3 MB
  120. Transaction Summary:
  121. Installing: 3 packages
  122. Reinstalling: 0 packages
  123. Upgrading: 0 packages
  124. Obsoleting: 0 packages
  125. Removing: 0 packages
  126. Downgrading: 0 packages
  127. Downloading packages…
  128. Running transaction test…
  129. Installing: libtirpc;1.1.4-5.0.1.el8;aarch64;ol8_baseos_latest
  130. Installing: libaio;0.3.112-1.el8;aarch64;ol8_baseos_latest
  131. Installing: mysql-community-server-minimal;8.0.28-1.el8;aarch64;mysql8.0-server-minimal
  132. Complete.
  133. + microdnf clean all
  134. + grep -F socket=/var/lib/mysql/mysql.sock /etc/my.cnf
  135. socket=/var/lib/mysql/mysql.sock
  136. + sed -i ‘s!^socket=.*!socket=/var/run/mysqld/mysqld.sock!’ /etc/my.cnf
  137. + grep -F socket=/var/run/mysqld/mysqld.sock /etc/my.cnf
  138. socket=/var/run/mysqld/mysqld.sock
  139. + echo ‘[client]’
  140. + echo socket=/var/run/mysqld/mysqld.sock
  141. + grep -F ‘!includedir’ /etc/my.cnf
  142. + echo
  143. + echo ‘!includedir /etc/mysql/conf.d/’
  144. + mkdir -p /etc/mysql/conf.d
  145. + mysqld –version
  146. /usr/sbin/mysqld Ver 8.0.28 for Linux on aarch64 (MySQL Community Server – GPL)
  147. + mysql –version
  148. mysql Ver 8.0.28 for Linux on aarch64 (MySQL Community Server – GPL)
  149. Removing intermediate container 5024aade5e13
  150. —> 75d6d11a0d4f
  151. 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
  152. —> Running in 370f3e954c65
  153. [mysql-tools-community]
  154. name=MySQL Tools Community
  155. baseurl=https://repo.mysql.com/yum/mysql-tools-community/el/8/$basearch/
  156. module_hotfixes=true
  157. Removing intermediate container 370f3e954c65
  158. —> 930aadf4bd26
  159. Step 14/20 : ENV MYSQL_SHELL_VERSION 8.0.28-1.el8
  160. —> Running in 12cb073265f5
  161. Removing intermediate container 12cb073265f5
  162. —> 146a70d69280
  163. Step 15/20 : RUN set -eux; microdnf install -y “mysql-shell-$MYSQL_SHELL_VERSION”; microdnf clean all; mysqlsh –version
  164. —> Running in ded458b7a5c5
  165. + microdnf install -y mysql-shell-8.0.28-1.el8
  166. Package Repository Size
  167. Installing:
  168. expat-2.2.5-4.0.1.el8_5.3.aarch64 ol8_baseos_latest 105.8 kB
  169. gdbm-libs-1:1.18-1.el8.aarch64 ol8_baseos_latest 60.5 kB
  170. libnsl2-1.2.0-2.20220605git4a062cf.el8.aarch64 ol8_baseos_latest 56.4 kB
  171. mysql-shell-8.0.28-1.el8.aarch64 mysql-tools-community 18.6 MB
  172. python39-libs-3.9.6-2.module+el8.5.0+20364+c7fe1181.aarch64 ol8_appstream 8.4 MB
  173. python39-pip-wheel-20.2.4-6.module+el8.5.0+20364+c7fe1181.noarch ol8_appstream 1.3 MB
  174. python39-setuptools-wheel-50.3.2-4.module+el8.5.0+20364+c7fe1181.noarch ol8_appstream 508.6 kB
  175. Installing: 7 packages
  176. Enabling module streams:
  177. python39:3.9
  178. Installing: python39-setuptools-wheel;50.3.2-4.module+el8.5.0+20364+c7fe1181;noarch;ol8_appstream
  179. Installing: python39-pip-wheel;20.2.4-6.module+el8.5.0+20364+c7fe1181;noarch;ol8_appstream
  180. Installing: libnsl2;1.2.0-2.20220605git4a062cf.el8;aarch64;ol8_baseos_latest
  181. Installing: gdbm-libs;1:1.18-1.el8;aarch64;ol8_baseos_latest
  182. Installing: expat;2.2.5-4.0.1.el8_5.3;aarch64;ol8_baseos_latest
  183. Installing: python39-libs;3.9.6-2.module+el8.5.0+20364+c7fe1181;aarch64;ol8_appstream
  184. Installing: mysql-shell;8.0.28-1.el8;aarch64;mysql-tools-community
  185. + mysqlsh –version
  186. Cannot set LC_ALL to locale en_US.UTF-8: No such file or directory
  187. mysqlsh Ver 8.0.28 for Linux on aarch64 – for MySQL 8.0.28 (MySQL Community Server (GPL))
  188. Removing intermediate container ded458b7a5c5
  189. —> 242cc65de9a1
  190. Step 16/20 : VOLUME /var/lib/mysql
  191. —> Running in 5cc99dcada97
  192. Removing intermediate container 5cc99dcada97
  193. —> fd89b8c734f5
  194. Step 17/20 : COPY docker-entrypoint.sh /usr/local/bin/
  195. —> 2793d27294e2
  196. Step 18/20 : ENTRYPOINT [“docker-entrypoint.sh”]
  197. —> Running in 057accf923c3
  198. Removing intermediate container 057accf923c3
  199. —> 39b58c0645c2
  200. Step 19/20 : EXPOSE 3306 33060
  201. —> Running in e08e5b46adfc
  202. Removing intermediate container e08e5b46adfc
  203. —> eed18bbc8cbd
  204. Step 20/20 : CMD [“mysqld”]
  205. —> Running in a356b9dc7916
  206. Removing intermediate container a356b9dc7916
  207. —> df723596f0a2
  208. Successfully built df723596f0a2
  209. Successfully tagged arm64uos/oracle-mysql:8.0

复制代码 到此这篇关于构建aarch64环境Mysql8.0的Docker镜像的文章就介绍到这了,更多相关Mysql  Docker镜像内容请搜索共生网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持共生网络!

原创文章,作者:starterknow,如若转载,请注明出处:https://www.starterknow.com/108298.html

联系我们