「更易用的OceanBase」| 制作自定义OceanBase容器——逆向思维(二)

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: 「更易用的OceanBase」| 制作自定义OceanBase容器——逆向思维

5. 第二次优化

  • 容器镜像大了200M,且本地存放文件太多,考虑两阶段构建
  • 考虑托管gitee然后打包tag方式下载rpm包,由于单个文件限制100M大小,放弃。
  • 最终发现OceanBase的官网发现了相关下载链接优化如下。
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:7.9.2009 as builder
RUN set -eux; \
    yum install wget -y && \
    mkdir /root/pkg/ && \
    cd /root/pkg/ && \
    yumdownloader libaio && \
    wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg && \
    wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm && \
    wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm
FROM centos:7.9.2009
COPY boot /root/boot/
COPY --from=builder /root/pkg/ /root/pkg/
RUN cd /root/pkg/ && \
    rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f bobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["_boot"]

6. 第二次构建

[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  68.61kB
Step 1/9 : FROM centos:7.9.2009 as builder
 ---> eeb6ee3f44bd
Step 2/9 : RUN set -eux;     yum install wget -y &&     mkdir /root/pkg/ &&     cd /root/pkg/ &&     yumdownloader libaio &&                                                                                                                wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-cent                                                                                                           er/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg &&     wget -O /root/pkg/libobclient-2.0.2-2.el7.                                                                                                           x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2                                                                                                           .el7.x86_64.rpm &&     wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*                                                                                                           ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm &&     wget -O /root/pkg/oceanbase-ce-libs-3.1.4-1                                                                                                           0000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileNam                                                                                                           e=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm &&     wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.                                                                                                           x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-                                                                                                           10000092022071511.el7.x86_64.rpm
 ---> Running in 63113118c822
+ yum install wget -y
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package        Arch             Version                   Repository      Size
================================================================================
Installing:
 wget           x86_64           1.14-18.el7_6.1           base           547 k
Transaction Summary
================================================================================
Install  1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80e                                                                                                           b5: NOKEY
Public key for wget-1.14-18.el7_6.1.x86_64.rpm is not installed
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-9.2009.0.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7_6.1.x86_64                                  1/1
install-info: No such file or directory for /usr/share/info/wget.info.gz
  Verifying  : wget-1.14-18.el7_6.1.x86_64                                  1/1
Installed:
  wget.x86_64 0:1.14-18.el7_6.1
Complete!
+ mkdir /root/pkg/
+ cd /root/pkg/
+ yumdownloader libaio
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bfsu.edu.cn
+ wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center                                                                                                           /opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg
--2022-10-31 04:52:04--  https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob                                                                                                           -deploy-1.5.0-12.el7.x86_64.rpm
Resolving obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)... 106.14.229.148
Connecting to obbusiness-private.oss-cn-shanghai.aliyuncs.com (obbusiness-private.oss-cn-shanghai.aliyuncs.com)|106.14.229.14                                                                                                           8|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34091424 (33M) [application/x-redhat-package-manager]
Saving to: '/root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm'
     0K .......... .......... .......... .......... ..........  0%  791K 42s
 ...
 ...
 33150K .......... .......... .......... .......... .......... 99% 11.8M 0s
 33200K .......... .......... .......... .......... .......... 99% 10.5M 0s
 33250K .......... .......... .......... .......... ..        100% 11.5M=3.1s
2022-10-31 04:52:07 (10.5 MB/s) - '/root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm' saved [34091424/34091424]
+ wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAA                                                                                                           AAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:07--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libob                                                                                                           client-2.0.2-2.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.249, 111.26.147.248, 2409:801a:3000:3:3::3f1, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 866256 (846K) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm'
     0K .......... .......... .......... .......... ..........  5%  852K 1s
    50K .......... .......... .......... .......... .......... 11% 2.10M 1s
   100K .......... .......... .......... .......... .......... 17% 2.34M 0s
   150K .......... .......... .......... .......... .......... 23% 10.9M 0s
   200K .......... .......... .......... .......... .......... 29% 11.1M 0s
   250K .......... .......... .......... .......... .......... 35% 2.81M 0s
   300K .......... .......... .......... .......... .......... 41% 6.14M 0s
   350K .......... .......... .......... .......... .......... 47% 4.13M 0s
   400K .......... .......... .......... .......... .......... 53% 8.77M 0s
   450K .......... .......... .......... .......... .......... 59% 5.05M 0s
   500K .......... .......... .......... .......... .......... 65% 4.51M 0s
   550K .......... .......... .......... .......... .......... 70% 11.8M 0s
   600K .......... .......... .......... .......... .......... 76% 8.23M 0s
   650K .......... .......... .......... .......... .......... 82% 12.5M 0s
   700K .......... .......... .......... .......... .......... 88% 11.3M 0s
   750K .......... .......... .......... .......... .......... 94% 9.65M 0s
   800K .......... .......... .......... .......... .....     100% 15.4M=0.2s
2022-10-31 04:52:08 (4.11 MB/s) - '/root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm' saved [866256/866256]
+ wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAA                                                                                                           AAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:08--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obcli                                                                                                           ent-2.0.2-3.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.248, 111.26.147.249, 2409:801a:3000:3:3::3f1, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 181903628 (173M) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/obclient-2.0.2-3.el7.x86_64.rpm'
     0K .......... .......... .......... .......... ..........  0%  804K 3m41s
    50K .......... .......... .......... .......... ..........  0% 2.26M 2m29s
...
...
177550K .......... .......... .......... .......... .......... 99% 8.81M 0s
177600K .......... .......... .......... ..........           100% 18.7M=16s
2022-10-31 04:52:24 (11.1 MB/s) - '/root/pkg/obclient-2.0.2-3.el7.x86_64.rpm' saved [181903628/181903628]
+ wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/fi                                                                                                           le/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:24--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=ocean                                                                                                           base-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.248, 111.26.147.249, 2409:801a:3000:3:3::3f2, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 158384 (155K) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm'
     0K .......... .......... .......... .......... .......... 32% 1.14M 0s
    50K .......... .......... .......... .......... .......... 64% 2.33M 0s
   100K .......... .......... .......... .......... .......... 96% 15.6M 0s
   150K ....                                                  100% 8911G=0.07s
2022-10-31 04:52:24 (2.25 MB/s) - '/root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm' saved [158384/158384]
+ wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm 'https://mdn.alipayobjects.com/ob_portal/afts/file/A*                                                                                                           qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm'
Warning: wildcards not supported in HTTP.
--2022-10-31 04:52:24--  https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=ocean                                                                                                           base-ce-3.1.4-10000092022071511.el7.x86_64.rpm
Resolving mdn.alipayobjects.com (mdn.alipayobjects.com)... 111.26.147.249, 111.26.147.248, 2409:801a:3000:3:3::3f2, ...
Connecting to mdn.alipayobjects.com (mdn.alipayobjects.com)|111.26.147.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49601860 (47M) [audio/x-pn-realaudio-plugin]
Saving to: '/root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm'
     0K .......... .......... .......... .......... ..........  0% 2.00M 24s
    50K .......... .......... .......... .......... ..........  0% 2.18M 23s
...
...
 48350K .......... .......... .......... .......... .......... 99% 9.32M 0s
 48400K .......... .......... .......... .........            100% 17.2M=4.3s
2022-10-31 04:52:28 (11.1 MB/s) - '/root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm' saved [49601860/49601860]
Removing intermediate container 63113118c822
 ---> b06583d94389
Step 3/9 : FROM centos:7.9.2009
 ---> eeb6ee3f44bd
Step 4/9 : COPY boot /root/boot/
 ---> 0f4a731d7dd2
Step 5/9 : COPY --from=builder /root/pkg/ /root/pkg/
 ---> 61c68a5edc42
Step 6/9 : RUN cd /root/pkg/ &&     rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109                                                                                                           -13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm &&     rm -rf /u01/mysql /u01/obclient/b                                                                                                           in/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&                                                                                                               rm -f bobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x                                                                                                           86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm &&     yum clean all
 ---> Running in 9b19e5cd0d53
warning: libaio-0.3.109-13.el7.i686.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ########################################
Updating / installing...
libobclient-2.0.2-2.el7               ########################################
obclient-2.0.2-3.el7                  ########################################
ob-deploy-1.5.0-12.el7                ########################################
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
libaio-0.3.109-13.el7                 ########################################
libaio-0.3.109-13.el7                 ########################################
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
Removing intermediate container 9b19e5cd0d53
 ---> 602ecb5fcf73
Step 7/9 : ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ---> Running in 380fa45a1746
Removing intermediate container 380fa45a1746
 ---> 2f8dd45b52ee
Step 8/9 : WORKDIR /root
 ---> Running in 16bc47928148
Removing intermediate container 16bc47928148
 ---> 0c2d0a0a6925
Step 9/9 : CMD ["_boot"]
 ---> Running in 31b07786a9ff
Removing intermediate container 31b07786a9ff
 ---> 5b8f291e6ec3
Successfully built 5b8f291e6ec3
Successfully tagged oceanbase:test
  • login
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase-test ob-mysql sys
login as root@sys
Command is: obclient -h127.1 -uroot@sys -A -Doceanbase -P2881
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221487745
Server version: 5.7.25 OceanBase 3.1.4 (r10000092022071511-b4bfa011ceaef428782dcb65ae89190c40b78c2f) (Built Jul 15 2022 11:45:14)
Copyright (c) 2000, 2022, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [oceanbase]>

7. 第三次优化

  • 由于两阶段构建多了一层COPY层大小,导致增加了200M容器大小,优化为一次构建。
  • 构建时间大致为1分钟,测试启动登录正常。
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:7.9.2009
COPY boot /root/boot/
RUN set -eux; \
    yum install wget -y && \
    mkdir /root/pkg/ && \
    cd /root/pkg/ && \
    yumdownloader libaio && \
    wget -O /root/pkg/ob-deploy-1.5.0-12.el7.x86_64.rpm https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/obdeploy/1.5.0/ob-deploy-1.5.0-12.el7.x86_64.rpm -P /root/pkg && \
    wget -O /root/pkg/libobclient-2.0.2-2.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*0-XHQZ8iONgAAAAAAAAAAAAADWF2AQ?af_fileName=libobclient-2.0.2-2.el7.x86_64.rpm && \
    wget -O /root/pkg/obclient-2.0.2-3.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*ycQqT7fFJ38AAAAAAAAAAAAADWF2AQ?af_fileName=obclient-2.0.2-3.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm && \
    rpm -ivh libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f libobclient-2.0.2-2.el7.x86_64.rpm libaio-0.3.109-13.el7.i686.rpm libaio-0.3.109-13.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm && \
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["_boot"]

8. 第四次优化

涉及到的知识点及优化方向

  • 核心思想是在不影响使用的前提下缩小image大小
  • 采用更小的Ubuntu基础镜像,OceanBase支持Ubuntu 20.X 版本及以上版本
  • 把转码后的文件上传的gitee上方便build使用减少本地COPY的镜像层大小
  • obclient大小超过100M不能上传到gitee,把rpm解压删除掉无用的东西并调试最终大小为50M左右,满足上传条件。
  • wget -O (下载文件名) -q(减少进度条输出,优化build输出)
  • observer二进制为后台命令,docker需要保持运行时,使用top -b保持运行
  • DEBIAN_FRONTEND=noninteractive TERM=dumb 解决top报错
  • CMD 传参observer 给ENTRYPOINT _boot(数据库安装脚本) 运行
  • vim和procps暂未安装有需求可以自行安装
  • rm 清理相关cache及处理后的中间文件,最终镜像大小402M 官方558M
  • image
[root@oceanbase1 ~]# docker image ls
REPOSITORY               TAG        IMAGE ID       CREATED             SIZE
oceanbase                test       876fbee4e01c   29 minutes ago      402MB
oceanbase/oceanbase-ce   latest     4af946862346   3 months ago        558MB
ubuntu                   20.04      ba6acccedd29   12 months ago       72.8MB
centos                   7.9.2009   eeb6ee3f44bd   13 months ago       204MB
  • Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM ubuntu:20.04
COPY boot /root/boot/
ENV DEBIAN_FRONTEND=noninteractive \
    PATH=/root/boot:/root/ob/bin:/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    LD_LIBRARY_PATH=LD_LIBRARY_PATH:/root/ob/lib \
    TERM=dumb
RUN set -eux; \
    apt-get update && apt-get install -y \
    libaio-dev  \
    krb5-locales  \
    libk5crypto3  \
    libkeyutils1  \
    libkrb5-3  \
    libkrb5support0 \
#    vim  \
    wget \
#    procps \
    libssl1.1 && \
    mkdir /root/pkg && cd /root/pkg/ && useradd admin && \
    wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q && \
    wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm  -q  && \
    wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q  && \
    wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q && \
    wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb  -q && \
    wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb  -q && \
    dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb && \
    dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb && \
    dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb && \
    tar -xf /root/pkg/obclient-3.1.4.tar.gz -C / && \
    cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb && \
    apt clean -y && \
    rm -rf \
    /var/cache/debconf/* \
    /var/lib/apt/lists/* \
    /var/log/* \
    /var/tmp/* \
    rm -rf /tmp/*
WORKDIR /root
ENTRYPOINT ["/root/boot/_boot"]
CMD ["observer"]
  • Build输出
[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  69.12kB
Step 1/7 : FROM ubuntu:20.04
 ---> ba6acccedd29
Step 2/7 : COPY boot /root/boot/
 ---> Using cache
 ---> 10d1472c6960
Step 3/7 : ENV DEBIAN_FRONTEND=noninteractive     PATH=/root/boot:/root/ob/bin:/u01/obclient/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin     LD_LIBRARY_PATH=LD_LIBRARY_PATH:/root/ob/lib     TERM=dumb
 ---> Using cache
 ---> a6734a678470
Step 4/7 : RUN set -eux;     apt-get update && apt-get install -y     libaio-dev      krb5-locales      libk5crypto3      libkeyutils1      libkrb5-3      libkrb5support0     wget     libssl1.1 &&     mkdir /root/pkg && cd /root/pkg/ && useradd admin &&     wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q &&     wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm  -q  &&     wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q  &&     wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q &&     wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb  -q &&     wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb  -q &&     dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb &&     dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb &&     dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb &&     tar -xf /root/pkg/obclient-3.1.4.tar.gz -C / &&     cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&    rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb &&     apt clean -y &&     rm -rf     /var/cache/debconf/*     /var/lib/apt/lists/*     /var/log/*     /var/tmp/*     rm -rf /tmp/*
 ---> Running in 358472898aeb
+ apt-get update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
...
...
Get:18 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [27.5 kB]
Fetched 24.2 MB in 1min 35s (255 kB/s)
Reading package lists...
+ apt-get install -y libaio-dev krb5-locales libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 wget libssl1.1
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  ca-certificates libaio1 libpsl5 openssl publicsuffix
Suggested packages:
  krb5-doc krb5-user
The following NEW packages will be installed:
  ca-certificates krb5-locales libaio-dev libaio1 libk5crypto3 libkeyutils1
  libkrb5-3 libkrb5support0 libpsl5 libssl1.1 openssl publicsuffix wget
0 upgraded, 13 newly installed, 0 to remove and 37 not upgraded.
Need to get 3079 kB of archives.
After this operation, 9126 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libssl1.1 amd64 1.1.1f-1ubuntu2.16 [1321 kB]
...
...
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 libaio-dev amd64 0.3.112-5 [13.7 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 3079 kB in 23s (133 kB/s)
...
...
Running hooks in /etc/ca-certificates/update.d...
done.
+ mkdir /root/pkg
+ cd /root/pkg/
+ useradd admin
+ wget -O /root/pkg/oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*yAluQr0F5gsAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-libs-3.1.4-10000092022071511.el7.x86_64.rpm -q
+ wget -O /root/pkg/oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm https://mdn.alipayobjects.com/ob_portal/afts/file/A*qjwRQ66mcuUAAAAAAAAAAAAADWF2AQ?af_fileName=oceanbase-ce-3.1.4-10000092022071511.el7.x86_64.rpm -q
+ wget -O /root/pkg/obclient-3.1.4.tar.gz https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/obclient-3.1.4.tar.gz -q
+ wget -O /root/pkg/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb -q
+ wget -O /root/pkg/libobclient_2.0.2-2.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/libobclient_2.0.2-2.el7_amd64.deb -q
+ wget -O /root/pkg/ob-deploy_1.5.0-12.el7_amd64.deb https://gitee.com/lee1002/oceanbase-depend/releases/download/oceanbase-3.1.4_depend_for_ubuntu/ob-deploy_1.5.0-12.el7_amd64.deb -q
+ dpkg --no-force-overwrite -i ob-deploy_1.5.0-12.el7_amd64.deb
Selecting previously unselected package ob-deploy.
(Reading database ... 4521 files and directories currently installed.)
Preparing to unpack ob-deploy_1.5.0-12.el7_amd64.deb ...
Unpacking ob-deploy (1.5.0-12.el7) ...
Setting up ob-deploy (1.5.0-12.el7) ...
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ dpkg --no-force-overwrite -i oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb
Selecting previously unselected package oceanbase-ce-libs.
(Reading database ... 5543 files and directories currently installed.)
Preparing to unpack oceanbase-ce-libs_3.1.4-10000092022071511.el7_amd64.deb ...
Unpacking oceanbase-ce-libs (3.1.4-10000092022071511.el7) ...
Setting up oceanbase-ce-libs (3.1.4-10000092022071511.el7) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ dpkg --no-force-overwrite -i libobclient_2.0.2-2.el7_amd64.deb
Selecting previously unselected package libobclient.
(Reading database ... 5554 files and directories currently installed.)
Preparing to unpack libobclient_2.0.2-2.el7_amd64.deb ...
Unpacking libobclient (2.0.2-2.el7) ...
Setting up libobclient (2.0.2-2.el7) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
+ tar -xf /root/pkg/obclient-3.1.4.tar.gz -C /
+ cd /root/pkg
+ rm -rf /usr/obd/mirror/remote/OceanBase.repo
+ rm -f obclient-3.1.4.tar.gz ob-deploy_1.5.0-12.el7_amd64.deb libobclient_2.0.2-2.el7_amd64.deb
+ apt clean -y
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
+ rm -rf /var/cache/debconf/config.dat /var/cache/debconf/config.dat-old /var/cache/debconf/passwords.dat /var/cache/debconf/templates.dat /var/cache/debconf/templates.dat-old /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-backports_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal-updates_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_InRelease /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_focal_universe_binary-amd64_Packages.lz4 /var/lib/apt/lists/auxfiles /var/lib/apt/lists/lock /var/lib/apt/lists/partial /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_InRelease /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_multiverse_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_restricted_binary-amd64_Packages.lz4 /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_focal-security_universe_binary-amd64_Packages.lz4 /var/log/alternatives.log /var/log/apt /var/log/bootstrap.log /var/log/btmp /var/log/dpkg.log /var/log/faillog /var/log/lastlog /var/log/wtmp /var/tmp/* rm -rf /tmp/*
Removing intermediate container 358472898aeb
 ---> 2d705657e597
Step 5/7 : WORKDIR /root
 ---> Running in ea13ce931bb6
Removing intermediate container ea13ce931bb6
 ---> 0f78b51886a9
Step 6/7 : ENTRYPOINT ["/root/boot/_boot"]
 ---> Running in f01ee0a12677
Removing intermediate container f01ee0a12677
 ---> ae636adc1a90
Step 7/7 : CMD ["observer"]
 ---> Running in ad3ba01022fc
Removing intermediate container ad3ba01022fc
 ---> 876fbee4e01c
Successfully built 876fbee4e01c
Successfully tagged oceanbase:test
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
7月前
|
存储 算法 C语言
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
229 0
|
6月前
|
监控 Serverless 文件存储
函数计算产品使用问题之如何确保新建的实例拉取的是最新的自定义容器镜像
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
|
4月前
|
C++ 容器
C++中自定义结构体或类作为关联容器的键
C++中自定义结构体或类作为关联容器的键
42 0
|
7月前
|
存储 弹性计算 运维
Docker数据集与自定义镜像:构建高效容器的关键要素
Docker数据集与自定义镜像:构建高效容器的关键要素
136 8
|
7月前
|
运维 安全 Linux
深入理解Docker自定义网络:构建高效的容器网络环境
深入理解Docker自定义网络:构建高效的容器网络环境
295 6
|
18天前
|
Kubernetes Cloud Native Docker
云原生时代的容器化实践:Docker和Kubernetes入门
【10月更文挑战第37天】在数字化转型的浪潮中,云原生技术成为企业提升敏捷性和效率的关键。本篇文章将引导读者了解如何利用Docker进行容器化打包及部署,以及Kubernetes集群管理的基础操作,帮助初学者快速入门云原生的世界。通过实际案例分析,我们将深入探讨这些技术在现代IT架构中的应用与影响。
59 2
|
8天前
|
Kubernetes Linux 开发者
深入探索容器化技术——Docker 的实战应用
深入探索容器化技术——Docker 的实战应用
36 5
|
11天前
|
运维 Cloud Native 云计算
云原生之旅:Docker容器化实战
本文将带你走进云原生的世界,深入理解Docker技术如何改变应用部署与运维。我们将通过实际案例,展示如何利用Docker简化开发流程,提升应用的可移植性和伸缩性。文章不仅介绍基础概念,还提供操作指南和最佳实践,帮助你快速上手Docker,开启云原生的第一步。
|
15天前
|
机器学习/深度学习 数据采集 Docker
Docker容器化实战:构建并部署一个简单的Web应用
Docker容器化实战:构建并部署一个简单的Web应用
|
13天前
|
运维 持续交付 虚拟化
深入解析Docker容器化技术的核心原理
深入解析Docker容器化技术的核心原理
35 1