容器服务 镜像分层最佳实践

这篇说说使用腾讯云TCR实现容器镜像分层构建与管理的最佳实践,通过F3S Docker Files项目展示从基础层到应用层的镜像构建流程,并说明TCR在资源复用、运维简化及镜像分发加速方面的优势。 镜像分层优势:共享资源提升利用率,TCR可加速大规模镜像分发5-10倍。 项目结构:F3S项目按0.base、1.ops、2.lang、3.app四层组织Dockerfile,覆盖Alpine、CentOS、Kona JD。

相关产品
容器服务 产品页,含版本规格、价格与购买入口。

一、操作场景

这篇说说如何把业务镜像分层构建与管理,使用 TCR 高效的管理各类容器镜像的最佳实践。

二、容器镜像分层的优势

·共享资源,提升资源利用率。

·镜像管理规范化与标准化,便于 DevOps 落地实施。

·TCR 的免运维、镜像加速,可轻松提升大规模镜像分发速度 5-10 倍。

·TCR 企业版内实例、命名空间、镜像仓库等资源的读写操作已接入操作审计,通过控制台进入审计日志即可查看相关操作记录。

三、前提条件

在使用 TCR 内托管的私有镜像进行应用部署前,你需要完成以下准备工作:

·已在 容器镜像服务 创建企业版实例。如尚未创建,请参考 创建企业版实例 完成创建。

·如果使用子账号进行操作,请参考 企业版授权方案示例 提前为子账号授予对应实例的操作权限。

注意:说明:

注意:已有容器镜像服务也适用,修改镜像仓库地址即可。

四、1. F3S Docker Files 介绍

项目由以下部分组成:

$ tree -L 3 ./f3s-docker-files./f3s-docker-files├── README.md —— 说明文件├── DockerBuildImages.sh —— 镜像构建脚本├── 0.base —— 0. 构建 Base 层各类系统镜像│ ├── alpine —— 构建 Base 层 alpine 系统镜像│ │ └── Dockerfile│ └── centos-7.8 —— 构建 Base 层 Centos7.8 系统镜像│ ├── Dockerfile│ └── centos-7.8.2003-x86_64-docker.tar.xz├─ 1.ops —— 1. 构建运维层各类镜像│ └── Dockerfile-alpine —— 构建运维层 alpine 镜像├── 2.lang —— 2. 构建语言层各类镜像│ └── Dockerfile-alpine-kona —— 语言层 alpine-kona 镜像 └── 3.app —— 3. 构建应用层各类镜像 ├── jmeter │ ├── Dockerfile-jmeter-base —— 构建 jmeter-base 镜像 │ ├── Dockerfile-jmeter-grafana-reporter —— 构建 jmeter-grafana-reporter 镜像 │ ├── Dockerfile-jmeter-master —— 构建 jmeter-master 镜像 │ └── Dockerfile-jmeter-slave —— 构建 jmeter-slave 镜像 ├── nginx │ ├── Dockerfile-alpine-nginx —— 构建 alpine-nginx 镜像 │ ├── default.conf │ └── nginx.conf └── skywalking └── Dockerfile-alpine-kona-skywalking —— 构建 alpine-kona-skywalking 镜像

·alpine/Dockerfile :使用 alpine 提供的 3.13 docker 镜像 构建,添加常用运维工具与中文支持等配置。

·centos-7.8/Dockerfile :使用 Centos 提供的 7.8 docker 镜像 构建,添加常用运维工具与中文支持等配置。

·Dockerfile-alpine-kona :使用 Dockerfile-alpine 和 TencentKona 8.0.5 二进制包 构建,为控制镜像大小对 Kona 做了部分裁剪。

·Dockerfile-jmeter-base :基于 JMeter 提供的 5.4.1 二进制包 构建。

·Dockerfile-jmeter-grafana-reporter :基于 Grafana-Reporter 构建 ,提供 Grafana 仪表板生成 JMeter PDF 报告的功能。

·Dockerfile-jmeter-master :基于 Jmeter-base 镜像构建,实现 Jmeter 分布式压测 Master 的功能。

·Dockerfile-jmeter-slave :基于 Jmeter-base 镜像构建,实现 Jmeter 分布式压测 Slave 的功能。

·Dockerfile-alpine-nginx :基于 Dockerfile-alpine 构建 ,添加 nginx 配置初始化与日志规范等配置。

·Dockerfile-alpine-kona-skywalking :使用 Dockerfile-alpine-kona 和 skywalking 提供的 8.5 二进制包 构建。

五、2.0 Dockerfile-alpine

============ALPINE DOCKER FILE============

# buildFROM alpine:3.13ENV FROM alpine:3.13# Alpine 镜像中并没有包含 tzdata,所以无法直接通过环境变量 TZ 设置时区,因此需要安装 tzdata:ENV TZ=Asia/ShanghaiRUN echo 'http://mirrors.tencent.com/alpine/v3.13/main/' > /etc/apk/repositories \\ && echo 'http://mirrors.tencent.com/alpine/v3.13/community/' >> /etc/apk/repositories \\ && apk –no-cache add apache2-utils \\ bind-tools \\ bridge-utils \\ busybox-extras \\ curl \\ ebtables \\ ethtool \\ fio \\ fping \\ iperf3 \\ iproute2 \\ iptables \\ iputils \\ ipvsadm \\ jq \\ lftp \\ lsof \\ mtr \\ netcat-openbsd \\ net-tools \\ nmap \\ procps \\ psmisc \\ rsync \\ smartmontools \\ strace \\ sysstat \\ tcpdump \\ tree \\ tzdata \\ unzip \\ util-linux \\ wget \\ zip \\ && echo "${TZ}" > /etc/timezone \\ && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \\ && rm -rf /var/cache/apk/*ENV BUILD f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:v3.13# docker build -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:v3.13 .

============Build, tag and push the base image============

cd $pwd/0.base/alpinedocker build -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:v3.13 -f Dockerfile .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:v3.13

六、2.1 Dockerfile-CentOS-7.8

============Centos-7.8 DOCKER FILE============

# build# centos 7.8 Dockerfile:https://github.com/CentOS/sig-cloud-instance-images/blob/CentOS-7.8.2003-x86_64/docker/Dockerfile# centos 7.8 包: wget https://raw.githubusercontent.com/CentOS/sig-cloud-instance-images/CentOS-7.8.2003-x86_64/docker/centos-7.8.2003-x86_64-docker.tar.xzFROM scratchADD centos-7.8.2003-x86_64-docker.tar.xz /LABEL name="CentOS Base Image" \\ vendor="CentOS" \\ license="GPLv2" \\ build-date="20200504"# 增加一些小工具,并修改时区RUN set -ex \\ && yum install -y wget \\ && rm -rf /etc/yum.repos.d/CentOS-* \\# 添加 Tencent yum 源 && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo \\ && yum fs filter documentation \\ && yum install -y atop \\ bind-utils \\ curl \\ dstat \\ ebtables \\ ethtool \\ fping \\ htop \\ iftop \\ iproute \\ jq \\ less \\ lsof \\ mtr \\ nc \\ net-tools \\ nmap-ncat \\ perf \\ psmisc \\ strace \\ sysstat \\ tcpdump \\ telnet \\ tree \\ unzip \\ wget \\ which \\ zip \\ ca-certificates \\ && rm -rf /etc/localtime \\ && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \\# Install dumb-init && wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64 \\ && chmod +x /usr/local/bin/dumb-init \\# Install gosu grab gosu for easy step-down from root# https://github.com/tianon/gosu/releases && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.13/gosu-amd64" \\ && chmod +x /usr/local/bin/gosu \\ && gosu nobody true \\# 安装中文语言包,解决中文乱码问题,vi 乱码需要这里解决 && yum -y install kde-l10n-Chinese glibc-common \\ && localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 \\ && export LC_ALL=zh_CN.utf8 \\ && yum clean all \\ && rm -rf /tmp/* \\ && rm -rf /var/lib/yum/* \\ && rm -rf /var/cache/yum# 解决 less 乱码问题ENV LESSCHARSET utf-8# 设置语言环境变量ENV LANG=en_US.UTF-8# 不加这句则 kubernetes 中的 stdin: true 和 tty: true 不生效CMD ["/bin/bash"]ENV BUILD f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8# docker build -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8 .

============Build, tag and push the base image============

cd $pwd/0.base/centos-7.8docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8 -f Dockerfile .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8# To test run: docker run –name test -it –rm f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8 uname -a# docker export <container-id> | docker import f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8# quick interative termnal: docker run -it –entrypoint=sh f3s-docker-file.tencentcloudcr.com/f3s-tcr/centos:v7.8 sh

七、2.2 Dockerfile-Ops

============Ops DOCKER FILE============

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:v3.13MAINTAINER westzhaoENV LANG=C.UTF-8# 下载运维工具RUN apk –no-progress –purge –no-cache add –upgrade wget \\ curl \\ mysql-client \\ busybox \\ busybox-extras \\ bash \\ bash-doc \\ bash-completion \\ tzdata \\ vim \\ unzip && \\# 下载 glibc 支持 jdk、解决中文支持问题 && \\wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \\ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.33-r0/glibc-2.33-r0.apk && \\ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.33-r0/glibc-bin-2.33-r0.apk && \\ wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.33-r0/glibc-i18n-2.33-r0.apk && \\ apk add glibc-2.33-r0.apk glibc-bin-2.33-r0.apk glibc-i18n-2.33-r0.apk && \\ rm glibc-2.33-r0.apk glibc-bin-2.33-r0.apk glibc-i18n-2.33-r0.apk && \\ /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 C.UTF-8 && \\ echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \\# 修改时区 mkdir -p /share/zoneinfo/Asia/ && \\ mkdir -p /etc/zoneinfo/Asia/ && \\ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \\ cp /usr/share/zoneinfo/Asia/Shanghai /share/zoneinfo/Asia/Shanghai && \\ cp /usr/share/zoneinfo/Asia/Shanghai /etc/zoneinfo/Asia/Shanghai && \\ echo "Asia/Shanghai" > /etc/timezone && \\ apk del tzdata && \\# 删除 apk 缓存 && \\ rm -rf /var/cache/apk/*

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latest -f ./1.ops/Dockerfile-alpine .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latest# To test run: docker run –name test -it –rm f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latest sh $(java -version)# docker export <container-id> | docker import f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latest# quick interative termnal: docker run -it –entrypoint=sh f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latest sh

八、2.3 Dockerfile-alpine-kona

============Alpine Kona DOCKER FILE============

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine:latestMAINTAINER westzhaoENV LANG=C.UTF-8# 通过 wget 下载 Kona 安装包 && \\RUN cd /opt && \\wget https://github.com/Tencent/TencentKona-8/releases/download/8.0.5-GA/TencentKona8.0.5.b12_jdk_linux-x86_64_8u282.tar.gz && \\ tar -xvf TencentKona8.0.5.b12_jdk_linux-x86_64_8u282.tar.gz && \\ rm TencentKona8.0.5.b12_jdk_linux-x86_64_8u282.tar.gz && \\ ln -nfs /opt/TencentKona-8.0.5-282 /opt/jdk && \\# 裁剪 jdk 未使用资源 && \\rm /opt/jdk/release && \\ rm /opt/jdk/THIRD_PARTY_README && \\ rm /opt/jdk/LICENSE && \\ rm /opt/jdk/ASSEMBLY_EXCEPTION && \\ rm -rf /opt/jdk/sample/ && \\ rm -rf /opt/jdk/demo/ && \\ rm -rf /opt/jdk/src.zip && \\ rm -rf /opt/jdk/man/ && \\ rm -rf /opt/jdk/lib/missioncontrol && \\ rm -rf /opt/jdk/lib/visualvm && \\ rm -rf /opt/jdk/lib/ant-javafx.jar && \\ rm -rf /opt/jdk/lib/javafx-mx.jar && \\ rm -rf /opt/jdk/lib/jconsole.jar && \\ rm -rf /opt/jdk/jre/lib/amd64/libawt_xawt.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjavafx_font_freetype.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjavafx_font_pango.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjavafx_font.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjavafx_font_t2k.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjavafx_iio.so && \\ rm -rf /opt/jdk/jre/lib/amd64/libjfxwebkit.so && \\ rm -rf /opt/jdk/jre/lib/desktop && \\ rm -rf /opt/jdk/jre/lib/ext/jfxrt.jar && \\ rm -rf /opt/jdk/jre/lib/fonts && \\ rm -rf /opt/jdk/jre/lib/locale/de && \\ rm -rf /opt/jdk/jre/lib/locale/fr && \\ rm -rf /opt/jdk/jre/lib/locale/it && \\ rm -rf /opt/jdk/jre/lib/locale/ja && \\ rm -rf /opt/jdk/jre/lib/locale/ko && \\ rm -rf /opt/jdk/jre/lib/locale/ko.UTF-8 && \\ rm -rf /opt/jdk/jre/lib/locale/pt_BR && \\ rm -rf /opt/jdk/jre/lib/locale/sv && \\ rm -rf /opt/jdk/jre/lib/locale/zh_HK.BIG5HK && \\ rm -rf /opt/jdk/jre/lib/locale/zh_TW && \\ rm -rf /opt/jdk/jre/lib/locale/zh_TW.BIG5 && \\ rm -rf /opt/jdk/jre/lib/oblique-fonts && \\ rm -rf /opt/jdk/jre/lib/deploy.jar && \\ rm -rf /opt/jdk/jre/lib/locale/# JAVA_HOMEENV JAVA_HOME=/opt/jdkENV CLASSPATH=.:$JAVA_HOME/lib/ENV PATH=$JAVA_HOME/bin:$PATH

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latest -f ./2.lang/Dockerfile-alpine-kona .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latest# To test run: docker run –name test -it –rm f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latest sh $(java -version)# docker export <container-id> | docker import f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latest# quick interative termnal: docker run -it –entrypoint=sh f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latest sh

九、2.4 Dockerfile-alpine-kona-skywalking

============Alpine Kona SkyWalking DOCKER FILE============

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latestMAINTAINER westzhaoENV LANG=C.UTF-8# 下载运维工具RUN mkdir /3.app && \\ wget -q -O /3.app/apache-skywalking-apm-8.5.0.tar.gz https://archive.apache.org/dist/skywalking/8.5.0/apache-skywalking-apm-8.5.0.tar.gz && \\ tar zxf /3.app/apache-skywalking-apm-8.5.0.tar.gz -C /3.app && \\ mv /3.app/apache-skywalking-apm-bin/agent /3.app/skywalking && \\ rm -rf /3.app/apache-skywalking-apm-8.5.0.tar.gz && \\ rm -rf /3.app/apache-skywalking-apm-bin/# JAVA_HOMEENV JAVA_HOME=/opt/jdkENV CLASSPATH=.:$JAVA_HOME/lib/ENV PATH=$JAVA_HOME/bin:$PATH

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona-skywalking:latest -f ./3.app/skywalking/Dockerfile-alpine-kona-skywalking .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona-skywalking:latest# To test run: docker run –name test -it –rm f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona-skywalking:latest sh $(java -version)# docker export <container-id> | docker import f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona-skywalking:latest# quick interative termnal: docker run -it –entrypoint=sh f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona-skywalking:latest sh

十、2.5 Dockerfile-jmeter-base

============JMETER BASE DOCKER FILE============

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latestMAINTAINER westzhaoARG JMETER_VERSION=5.4.1# 下载 jmeterRUN mkdir /jmeter && \\cd /jmeter && \\wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz && \\ tar -xzf apache-jmeter-$JMETER_VERSION.tgz && \\ rm apache-jmeter-$JMETER_VERSION.tgz && \\# 下载 JMeterPlugins-Standard && \\cd /jmeter/apache-jmeter-$JMETER_VERSION/ && \\ wget -q -O /tmp/JMeterPlugins-Standard-1.4.0.zip https://jmeter-plugins.org/downloads/file/JMeterPlugins-Standard-1.4.0.zip && \\ unzip -n /tmp/JMeterPlugins-Standard-1.4.0.zip && \\ rm /tmp/JMeterPlugins-Standard-1.4.0.zip && \\# 下载 pepper-box && \\ wget -q -O /jmeter/apache-jmeter-$JMETER_VERSION/lib/ext/pepper-box-1.0.jar https://github.com/raladev/load/blob/master/JARs/pepper-box-1.0.jar?raw=true && \\# 下载 bzm-parallel && \\cd /jmeter/apache-jmeter-$JMETER_VERSION/ && \\ wget -q -O /tmp/bzm-parallel-0.7.zip https://jmeter-plugins.org/files/packages/bzm-parallel-0.7.zip && \\ unzip -n /tmp/bzm-parallel-0.7.zip && \\ rm /tmp/bzm-parallel-0.7.zipENV JMETER_HOME /jmeter/apache-jmeter-$JMETER_VERSION/ENV PATH $JMETER_HOME/bin:$PATH

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-base:latest -f ./3.app/jmeter/Dockerfile-jmeter-base .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-base:latest

十一、2.6 Dockerfile-jmeter-master

============JMETER-MASTER DOCKER FILE============

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-base:latestMAINTAINER westzhaoEXPOSE 60000

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-master:latest -f ./3.app/jmeter/Dockerfile-jmeter-master .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-master:latest

十二、2.7 Dockerfile-jmeter-slave

================JMETER-SLAVES DOCKER FILE=====================

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-base:latestMAINTAINER westzhaoEXPOSE 1099 50000ENTRYPOINT $JMETER_HOME/bin/jmeter-server \\-Dserver.rmi.localport=50000 \\-Dserver_port=1099 \\-Jserver.rmi.ssl.disable=true

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-slave:latest -f ./3.app/jmeter/Dockerfile-jmeter-slave .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-slave:latest

十三、2.8 Dockerfile-jmeter-grafana-reporter

================JMETER-GRAFANA-REPORTER DOCKER FILE=====================

# build# 多阶构建FROM golang:1.14.7-alpine3.12 AS buildMAINTAINER westzhao# 下载运维/编译工具WORKDIR /go/src/${owner:-github.com/8710925}/reporter# ADD . .# RUN go install -v github.com/8710925/reporter/cmd/grafana-reporterRUN apk –no-progress –purge –no-cache add –upgrade git && \\# 编译 grafana-reporter git clone https://${owner:-github.com/8710925}/reporter . \\ && go install -v github.com/8710925/reporter/cmd/grafana-reporter# create grafana reporter imageFROM alpine:3.12COPY –from=build /go/src/${owner:-github.com/8710925}/reporter/util/texlive.profile /COPY –from=build /go/src/${owner:-github.com/8710925}/reporter/util/SIMKAI.ttf /usr/share/fonts/west/RUN apk –no-progress –purge –no-cache add –upgrade wget \\ curl \\ fontconfig \\ unzip \\ tzdata \\ perl-switch && \\ wget -qO- \\ "https://raw.githubusercontent.com/rstudio/tinytex/main/tools/install-unx.sh" | \\ sh -s – –admin –no-path \\ && mv ~/.TinyTeX /opt/TinyTeX \\ && /opt/TinyTeX/bin/*/tlmgr path add \\ && tlmgr path add \\ && chown -R root:adm /opt/TinyTeX \\ && chmod -R g+w /opt/TinyTeX \\ && chmod -R g+wx /opt/TinyTeX/bin \\ && tlmgr update –self –repository http://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet \\ && tlmgr install epstopdf-pkg ctex everyshi everysel euenc \\# 修改时区 && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \\ && echo "Asia/Shanghai" > /etc/timezone \\ && apk del tzdata \\ # Cleanup && fmtutil-sys –all \\ && texhash \\ && mktexlsr \\ && apk del –purge -qq \\ && rm -rf /var/lib/apt/lists/*COPY –from=build /go/bin/grafana-reporter /usr/local/binENTRYPOINT [ "/usr/local/bin/grafana-reporter","-ip","jmeter-grafana:3000" ]

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-grafana-reporter:latest -f ./3.app/jmeter/Dockerfile-jmeter-grafana-reporter .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/jmeter-grafana-reporter:latest

十四、2.9 Dockerfile-alpine-nginx

================Alpine Nginx DOCKER FILE=====================

# buildFROM f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-kona:latestMAINTAINER westzhaoENV LANG=C.UTF-8# 下载运维工具RUN apk –no-progress –purge –no-cache add –upgrade nginx && \\# 删除 apk 缓存 && \\ rm -rf /var/cache/apk/*COPY ./3.app/nginx/default.conf /etc/nginx/http.d/default.confCOPY ./3.app/nginx/nginx.conf /etc/nginx/nginx.confEXPOSE 80 443CMD ["/usr/sbin/nginx", "-g", "daemon off;", "-c", "/etc/nginx/nginx.conf"]

============Build, tag and push the base image============

docker build –no-cache -t f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-nginx:latest -f ./3.app/nginx/Dockerfile-alpine-nginx .docker push f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-nginx:latest# To test run: docker run –name test -it –rm -p 8888:80 f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-nginx:latest nginx -v# docker export <container-id> | docker import f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-nginx:latest# quick interative termnal: docker run -it –entrypoint=sh f3s-docker-file.tencentcloudcr.com/f3s-tcr/alpine-nginx:latest sh

赞 (0)
上一篇 4天前
下一篇 4天前