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

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
简介: 「更易用的OceanBase」| 制作自定义OceanBase容器——逆向思维

前言


使用容器版本安装部署数据库时,是为了更方便便捷的使用,作者在使用OceanBase容器版本部署的时候并未发现相关的Dockerfile且镜像较大,这就导致不能更好的自定义功能,有些背离了容器版本的初衷。

本文利用docker history命令从镜像层剥离dockerfile的相关命令,然后从运行的容器里反推找到boot,涉及到的安装包依赖环境,最终实现dockerfile的编写,替换基础镜像为Ubuntu,最终镜像大小减少了150MB,文末提供了阿里云和docker hub镜像地址及dockerfile 码云地置,欢迎大家测试使用。

一、安装Docker

1. 安装并启动Docker

[root@oceanbase1 ~]# yum install -y yum-utils   device-mapper-persistent-data   lvm2
[root@oceanbase1 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@oceanbase1 ~]# yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
[root@oceanbase1 ~]# systemctl start docker
[root@oceanbase1 ~]# systemctl enable docker

二、解析Dockerfile

1. pull

[root@oceanbase1 ~]# docker pull oceanbase/oceanbase-ce
Using default tag: latest
latest: Pulling from oceanbase/oceanbase-ce
13add961a70d: Pull complete
c8175aff0e18: Pull complete
39c994bcc219: Pull complete
71a870d28c6f: Pull complete
Digest: sha256:6c3f458abc38a017e604af1188726174b6dc81f38c96e2869dc2cb04931a8cd8
Status: Downloaded newer image for oceanbase/oceanbase-ce:latest
docker.io/oceanbase/oceanbase-ce:latest

2. 解析

  • 从create by字段提取部分dockerfile内容
[root@oceanbase1 ~]# docker history 4af946862346 --no-trunc
IMAGE                                                                     CREATED         CREATED BY                                                                                                                                                                                                                                                                                                                                                                                           SIZE      COMMENT
sha256:4af94686234630b4e86297637deefbb6e090f1893545aa803dec03269c3e62ca   3 months ago    /bin/sh -c #(nop)  CMD ["/bin/sh" "-c" "_boot"]                                                                                                                                                                                                                                                                                                                                                      0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop) WORKDIR /root                                                                                                                                                                                                                                                                                                                                                                      0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop)  ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                                                                                                                                                  0B
<missing>                                                                 3 months ago    /bin/sh -c #(nop) COPY dir:8ca8c9383f9767b320dbc0cab03d57ccb39997339cf90b023c4348232edc46e5 in /root/boot/                                                                                                                                                                                                                                                                                           5.32kB
<missing>                                                                 3 months ago    |1 VERSION=3.1.4-10000092022071511 /bin/sh -c mkdir /root/pkg &&     cd /root/pkg &&     wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-${VERSION}.el7.x86_64.rpm -q &&     wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-${VERSION}.el7.x86_64.rpm -q &&     rm -rf /usr/obd/mirror/remote/* &&     yum clean all   51.5MB
<missing>                                                                 3 months ago    |1 VERSION=3.1.4-10000092022071511 /bin/sh -c yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     yum install -y ob-deploy obclient ob-sysbench wget libaio &&     rm -rf /usr/obd/mirror/remote/* &&     rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     yum clean all                                     292MB
<missing>                                                                 3 months ago    /bin/sh -c #(nop)  ARG VERSION=3.1.3-10100032022041510                                                                                                                                                                                                                                                                                                                                               0B
<missing>                                                                 15 months ago                                                                                                                                                                                                                                                                                                                                                                                                        214MB
  • 找到基础镜像
[root@oceanbase1 oceanbase-docker]# docker start e6318f6ec467
e6318f6ec467
[root@oceanbase1 oceanbase-docker]# docker exec -it oceanbase-ce bash
[root@e6318f6ec467 ~]#
[root@e6318f6ec467 ~]#
[root@e6318f6ec467 ~]# lsb_release
LSB Version:    :core-4.1-amd64:core-4.1-noarch
[root@e6318f6ec467 ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core
  • 初版Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:centos7.9.2009
COPY boot /root/boot/
RUN VERSION=3.1.4-10000092022071511 yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \
    yum install -y ob-deploy obclient ob-sysbench wget libaio &&  \
    rm -rf /usr/obd/mirror/remote/* &&  \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    yum clean all
RUN VERSION=3.1.4-10000092022071511 mkdir /root/pkg && \
    cd /root/pkg && wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-${VERSION}.el7.x86_64.rpm -q && \
    wget https://mirrors.aliyun.com/oceanbase/community/stable/el/7/x86_64/oceanbase-ce-libs-${VERSION}.el7.x86_64.rpm -q && \
    rm -rf /usr/obd/mirror/remote/* &&\
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["/bin/sh" "-c" "_boot"]
  • 从已有的容器里拷贝_boot
[root@oceanbase1 oceanbase-docker]# docker cp e6318f6ec467:/root/_boot .

三、构建与优化

1. 第一次构建

[root@oceanbase1 oceanbase-docker]# pwd
/root/oceanbase-docker
[root@oceanbase1 oceanbase-docker]# ls
boot  Dockerfile
[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  188.1MB
Step 1/7 : FROM centos:centos7.9.2009
 ---> eeb6ee3f44bd
Step 2/7 : COPY boot /root/boot/
 ---> Using cache
 ---> 7af2ff5bab30
Step 3/7 : RUN VERSION=3.1.4-10000092022071511 yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     yum install -y ob-deploy obclient ob-sysbench wget libaio &&      rm -rf /usr/obd/mirror/remote/* &&      rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     yum clean all
 ---> Running in 39431507a097
Loaded plugins: fastestmirror, ovl
adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo
grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo
repo saved to /etc/yum.repos.d/OceanBase.repo
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package ob-deploy.x86_64 0:1.5.0-12.el7 will be installed
---> Package ob-sysbench.x86_64 0:1.0.20-3.el7 will be installed
---> Package obclient.x86_64 0:2.0.2-3.el7 will be installed
--> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.2-3.el7.x86_64
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Running transaction check
---> Package libobclient.x86_64 0:2.0.2-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package       Arch     Version              Repository                    Size
================================================================================
Installing:
 libaio        x86_64   0.3.109-13.el7       base                          24 k
 ob-deploy     x86_64   1.5.0-12.el7         oceanbase.community.stable    33 M
 ob-sysbench   x86_64   1.0.20-3.el7         oceanbase.development-kit    346 k
 obclient      x86_64   2.0.2-3.el7          oceanbase.community.stable   173 M
 wget          x86_64   1.14-18.el7_6.1      base                         547 k
Installing for dependencies:
 libobclient   x86_64   2.0.2-2.el7          oceanbase.community.stable   847 k
Transaction Summary
================================================================================
Install  5 Packages (+1 Dependent package)
Total download size: 208 M
Installed size: 802 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/libaio-0.3.109-13.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for libaio-0.3.109-13.el7.x86_64.rpm is not installed
warning: /var/cache/yum/x86_64/7/oceanbase.development-kit/packages/ob-sysbench-1.0.20-3.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID e9b4a7aa: NOKEY
Public key for ob-sysbench-1.0.20-3.el7.x86_64.rpm is not installed
Public key for libobclient-2.0.2-2.el7.x86_64.rpm is not installed
^C

2. 第一次优化

  • 会hang在这里很久(因为rpm下载太慢了),且有些warning。我们来优化一下。
  • 提前下载好rpm
  • yum 加上 --nogpgcheck
[root@oceanbase1 rpm]# yumdownloader ob-deploy obclient ob-sysbench wget libaio
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
(1/5): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                               |  24 kB  00:00:00
(2/5): libaio-0.3.109-13.el7.i686.rpm                                                                                                                 |  24 kB  00:00:00
(3/5): ob-sysbench-1.0.20-3.el7.x86_64.rpm                                                                                                            | 346 kB  00:00:01
(4/5): ob-deploy-1.5.0-12.el7.x86_64.rpm                                                                                                              |  33 MB  00:02:54
(5/5): obclient-2.0.2-3.el7.x86_64.rpm                                                                                                                | 173 MB  00:18:35
  • 由于缺少resolve忘记解决依赖,这里再下载一次解决依赖
error: Failed dependencies:
        libobclient >= 2.0.0 is needed by obclient-2.0.2-3.el7.x86_64
[root@oceanbase1 rpm]# yumdownloader ob-deploy obclient ob-sysbench wget libaio --resolve
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
--> Running transaction check
---> Package libaio.i686 0:0.3.109-13.el7 will be installed
---> Package libaio.x86_64 0:0.3.109-13.el7 will be reinstalled
---> Package ob-deploy.x86_64 0:1.5.0-12.el7 will be reinstalled
---> Package ob-sysbench.x86_64 0:1.0.20-3.el7 will be installed
---> Package obclient.x86_64 0:2.0.2-3.el7 will be installed
--> Processing Dependency: libobclient >= 2.0.0 for package: obclient-2.0.2-3.el7.x86_64
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Running transaction check
---> Package libobclient.x86_64 0:2.0.2-2.el7 will be installed
--> Finished Dependency Resolution
libobclient-2.0.2-2.el7.x86_64.rpm                                                                                                                    | 847 kB  00:00:07
[root@oceanbase1 oceanbase-docker]# ls
boot  Dockerfile  pkg
[root@oceanbase1 oceanbase-docker]# ls pkg/
libaio-0.3.109-13.el7.i686.rpm      obclient-2.0.2-3.el7.x86_64.rpm      wget-1.14-18.el7_6.1.x86_64.rpm
libaio-0.3.109-13.el7.x86_64.rpm    ob-deploy-1.5.0-12.el7.x86_64.rpm
libobclient-2.0.2-2.el7.x86_64.rpm  ob-sysbench-1.0.20-3.el7.x86_64.rpm
  • Dockerfile
[root@oceanbase1 oceanbase-docker]# cat Dockerfile
FROM centos:centos7.9.2009
COPY boot /root/boot/
COPY pkg /root/pkg/
RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo && \
    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 wget-1.14-18.el7_6.1.x86_64.rpm ob-sysbench-1.0.20-3.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7.x86_64.rpm --nosignature && \
    rm -rf /usr/obd/mirror/remote/* &&  \
    rm -rf /u01/mysql /u01/obclient/bin/mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* && \
    yum clean all
RUN  cd /root/pkg && \
    rm -rf /usr/obd/mirror/remote/* &&\
    yum clean all
ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /root
CMD ["_boot"]

3. 第二次构建

[root@oceanbase1 oceanbase-docker]# docker build -t oceanbase:test .
Sending build context to Docker daemon  267.6MB
Step 1/8 : FROM centos:centos7.9.2009
 ---> eeb6ee3f44bd
Step 2/8 : COPY boot /root/boot/
 ---> 24c19ac56e04
Step 3/8 : COPY pkg /root/pkg/
 ---> e38480da210a
Step 4/8 : RUN yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo &&     cd /root/pkg/ &&    wget-1.14-18.el7_6.1.x86_64.rpm ob-sysbench-1.0.20-3.el7.x86_64.rpm obclient-2.0.2-3.el7.x86_64.rpm ob-deploy-1.5.0-12.el7mysqld* /u01/obclient/bin/aria* /u01/obclient/bin/maria* &&     yum clean all
 ---> Running in 4114dfe9a87d
Loaded plugins: fastestmirror, ovl
adding repo from: https://mirrors.aliyun.com/oceanbase/OceanBase.repo
grabbing file https://mirrors.aliyun.com/oceanbase/OceanBase.repo to /etc/yum.repos.d/OceanBase.repo
repo saved to /etc/yum.repos.d/OceanBase.repo
Preparing...                          ########################################
Updating / installing...
libobclient-2.0.2-2.el7               ########################################
obclient-2.0.2-3.el7                  ########################################
ob-sysbench-1.0.20-3.el7              ########################################
Please execute 'sysbench --help' for more information.
ob-deploy-1.5.0-12.el7                ########################################
Installation of obd finished successfully
Please source /etc/profile.d/obd.sh to enable it
wget-1.14-18.el7_6.1                  ########################################
libaio-0.3.109-13.el7                 ########################################
libaio-0.3.109-13.el7                 ########################################
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras oceanbase.community.stable oceanbase.development-kit
              : updates
Removing intermediate container 4114dfe9a87d
 ---> b37b0839eee8
Step 5/8 : RUN  cd /root/pkg &&     rm -rf /usr/obd/mirror/remote/* &&    yum clean all
 ---> Running in 60a2414469b0
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras oceanbase.community.stable oceanbase.development-kit
              : updates
Removing intermediate container 60a2414469b0
 ---> 7af143f83ce7
Step 6/8 : ENV PATH=/root/boot:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 ---> Running in 72f0ff83e8b7
Removing intermediate container 72f0ff83e8b7
 ---> ede9c5ba9d54
Step 7/8 : WORKDIR /root
 ---> Running in e623e0996d35
Removing intermediate container e623e0996d35
 ---> 0234ff905a4f
Step 8/8 : CMD ["_boot"]
 ---> Running in d580c4e5789a
Removing intermediate container d580c4e5789a
 ---> 25185d7fa0e9
Successfully built 25185d7fa0e9
Successfully tagged oceanbase:test

4. 启动测试

  • run
[root@oceanbase1 oceanbase-docker]# docker run -p 2881:2881 --name oceanbase-test -e MINI_MODE=1 -d oceanbase:test
a45de8f8730fc6bba2acd69792e9cf067e37581bf3a72e5a42a4e563c03904ff
[root@oceanbase1 oceanbase-docker]# docker logs -f oceanbase-test
generate boot.yaml ...
oceanbase-ce docker in mini mode
create boot dirs and deploy ob cluster ...
...
...
name: wget
version: 1.14
release:18.el7_6.1
arch: x86_64
md5: c87f4d3b21d1cb8509fbaadb65eeefc7ca579064
add /root/pkg/wget-1.14-18.el7_6.1.x86_64.rpm to local mirror
+---------------------------------------------------------------------------------------------------------+
|                                            local Package List                                           |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| name              | version | release               | arch   | md5                                      |
+-------------------+---------+-----------------------+--------+------------------------------------------+
| libaio            | 0.3.109 | 13.el7                | i686   | b1f4b46fe5bf353650905a8e7965710f3831e18d |
| libaio            | 0.3.109 | 13.el7                | x86_64 | a6059890e3323e2a5d0a372e4e3d6f1399dc5c76 |
| libobclient       | 2.0.2   | 2.el7                 | x86_64 | 9380b4f5ca295ce75ae56db4f0f09b4effd2e704 |
| ob-deploy         | 1.5.0   | 12.el7                | x86_64 | 5406e26462200de99df15b8f4ef062beb7f6c52a |
| ob-sysbench       | 1.0.20  | 3.el7                 | x86_64 | b611500b4bdaa0dc680ac6b5808a10185b71231b |
| obclient          | 2.0.2   | 3.el7                 | x86_64 | 4b180b2b1ee84f282cf39bf4f585df010f62b9a6 |
| oceanbase-ce      | 3.1.4   | 10000092022071511.el7 | x86_64 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
| oceanbase-ce-libs | 3.1.4   | 10000092022071511.el7 | x86_64 | 6d5437b0cad486b55963f89b8ef3769af7995350 |
| wget              | 1.14    | 18.el7_6.1            | x86_64 | c87f4d3b21d1cb8509fbaadb65eeefc7ca579064 |
+-------------------+---------+-----------------------+--------+------------------------------------------+
Local deploy is empty
Package oceanbase-ce-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-3.1.4 for local ok
Cluster param config check ok
Open ssh connection ok
Generate observer configuration ok
oceanbase-ce-3.1.4 already installed.
+-------------------------------------------------------------------------------------------+
|                                          Packages                                         |
+--------------+---------+-----------------------+------------------------------------------+
| Repository   | Version | Release               | Md5                                      |
+--------------+---------+-----------------------+------------------------------------------+
| oceanbase-ce | 3.1.4   | 10000092022071511.el7 | c5cd94f4f190317b6a883c58a26460a506205ce6 |
+--------------+---------+-----------------------+------------------------------------------+
Repository integrity check ok
Parameter check ok
Open ssh connection ok
Cluster status check ok
Initializes observer work home ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check !!
Try to get lib-repository
Package oceanbase-ce-libs-3.1.4-10000092022071511.el7 is available.
install oceanbase-ce-libs-3.1.4 for local ok
Remote oceanbase-ce-libs-3.1.4-10000092022071511.el7-6d5437b0cad486b55963f89b8ef3769af7995350 repository install ok
Remote oceanbase-ce-3.1.4-10000092022071511.el7-c5cd94f4f190317b6a883c58a26460a506205ce6 repository lib check ok
obcluster deployed
Get local repositories ok
Search plugins ok
Open ssh connection ok
Load cluster param plugin ok
Check before start observer ok
[WARN] OBD-1007: (127.0.0.1) The recommended number of open files is 655350 (Current value: %s)
[WARN] (127.0.0.1) clog and data use the same disk (/)
Start observer ok
observer program health check ok
Connect to observer ok
Initialize cluster
Cluster bootstrap ok
Wait for observer init ok
+---------------------------------------------+
|                   observer                  |
+-----------+---------+------+-------+--------+
| ip        | version | port | zone  | status |
+-----------+---------+------+-------+--------+
| 127.0.0.1 | 3.1.4   | 2881 | zone1 | active |
+-----------+---------+------+-------+--------+
obcluster running
Get local repositories and plugins ok
Open ssh connection ok
Connect to observer ok
Create tenant test ok
deploy success!
boot success!
^C
  • 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 3221487634
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]> select version();
+--------------------+
| version()          |
+--------------------+
| 3.1.4-OceanBase CE |
+--------------------+
1 row in set (0.007 sec)
obclient [oceanbase]>
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
3月前
|
存储 算法 C语言
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
【C++ 迭代器实现 终篇】深入理解C++自定义容器和迭代器的实现与应用
132 0
|
6天前
|
C++ 容器
C++中自定义结构体或类作为关联容器的键
C++中自定义结构体或类作为关联容器的键
13 0
|
2月前
|
监控 Serverless 文件存储
函数计算产品使用问题之如何确保新建的实例拉取的是最新的自定义容器镜像
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
|
3月前
|
存储 弹性计算 运维
Docker数据集与自定义镜像:构建高效容器的关键要素
Docker数据集与自定义镜像:构建高效容器的关键要素
|
3月前
|
运维 安全 Linux
深入理解Docker自定义网络:构建高效的容器网络环境
深入理解Docker自定义网络:构建高效的容器网络环境
196 6
|
9天前
|
Docker 容器
Docker cp 将宿主机上的文件复制到容器中
Docker cp 将宿主机上的文件复制到容器中
11 0
|
4天前
|
JSON JavaScript 开发者
Composerize神器:自动化转换Docker运行命令至Compose配置,简化容器部署流程
【8月更文挑战第7天】Composerize神器:自动化转换Docker运行命令至Compose配置,简化容器部署流程
Composerize神器:自动化转换Docker运行命令至Compose配置,简化容器部署流程
|
1天前
|
缓存 开发者 Docker
Dockerfile是Docker容器化过程中的核心组件,它允许开发者以一种可重复、可移植的方式自动化地构建Docker镜像
【8月更文挑战第19天】Dockerfile是构建Docker镜像的脚本文件,含一系列指令定义镜像构建步骤。每条大写指令后跟至少一个参数,按序执行,每执行一条指令即生成新的镜像层。常用指令包括:FROM指定基础镜像;RUN执行构建命令;EXPOSE开放端口;CMD指定容器启动行为等。优化策略涉及减少镜像层数、选择轻量基础镜像、利用缓存及清理冗余文件。示例:基于Python应用的Dockerfile包括设置工作目录、复制文件、安装依赖等步骤。掌握Dockerfile有助于高效自动化构建镜像,加速应用部署。
|
6天前
|
监控 Ubuntu Docker
如何在Docker容器启动时自动运行脚本
【8月更文挑战第13天】在Docker容器启动时自动运行脚本可通过以下方式实现:1) 使用`ENTRYPOINT`或`CMD`指令在Dockerfile中直接指定启动脚本,如`ENTRYPOINT [&quot;/startup.sh&quot;]`;2) 启动容器时通过`--entrypoint`参数指定脚本路径;3) 利用supervisor等进程管理工具自动启动与监控脚本,确保其稳定运行。确保脚本具有执行权限并正确设置依赖资源路径。
|
14天前
|
Shell 云计算 Docker
零基础到容器技术大神,一键解锁Docker实战秘籍!从零搭建,见证你的技术飞跃,让代码在云端翩翩起舞!
【8月更文挑战第5天】在云计算与微服务当道的今天,容器技术如汹涌浪潮般席卷IT领域。对新手而言,它或许充满神秘,但无须担忧,让我们一同揭开它的面纱。容器是一种轻量级软件打包技术,允许应用及其依赖被打包,在独立的虚拟环境中运行。Docker作为容器界的明星,简化了容器的创建与管理。从安装Docker开始,运行首个容器,深入容器内部执行命令,直至构建自定义镜像,我们将逐步掌握这项关键技术。这不仅是一场技术之旅,更是思维方式的革新,让我们携手探索未来。
56 6