经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » Docker » 查看文章
关于构建aarch64环境Mysql8.0的Docker镜像问题
来源:jb51  时间:2022/4/18 10:10:52  对本文有异议

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; 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
  8. chmod 1777 /var/lib/mysql /var/run/mysqld; mkdir /docker-entrypoint-initdb.d
  9. # add gosu for easy step-down from root
  10. # https://github.com/tianon/gosu/releases
  11. ENV GOSU_VERSION 1.14
  12. COPY ./gosu-arm64 /usr/local/bin/gosu
  13. COPY ./gosu-arm64.asc /usr/local/bin/gosu.asc
  14. RUN set -eux; # TODO find a better userspace architecture detection method than querying the kernel
  15. 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
  16. RUN set -eux; microdnf install -y gzip openssl xz zstd # Oracle Linux 8+ is very slim :)
  17. findutils ; microdnf clean all
  18. RUN set -eux; # https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
  19. # gpg: key 3A79BD29: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
  20. 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"
  21. ENV MYSQL_MAJOR 8.0
  22. ENV MYSQL_VERSION 8.0.28-1.el8
  23. 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
  24. echo 'module_hotfixes=true'; } | tee /etc/yum.repos.d/mysql-community-minimal.repo
  25. 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)
  26. # https://github.com/docker-library/mysql/pull/680#issuecomment-636121520
  27. 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
  28. ! 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
  29. 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
  30. echo 'module_hotfixes=true'; } | tee /etc/yum.repos.d/mysql-community-tools.repo
  31. ENV MYSQL_SHELL_VERSION 8.0.28-1.el8
  32. RUN set -eux; microdnf install -y "mysql-shell-$MYSQL_SHELL_VERSION"; microdnf clean all; mysqlsh --version
  33. VOLUME /var/lib/mysql
  34. COPY docker-entrypoint.sh /usr/local/bin/
  35. ENTRYPOINT ["docker-entrypoint.sh"]
  36. EXPOSE 3306 33060
  37. 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.20180605git4a062cf.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.20180605git4a062cf.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镜像内容请搜索w3xue以前的文章或继续浏览下面的相关文章希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号