blank
blank
发布于 2019-11-22 / 557 阅读 / 0 评论 / 0 点赞

docker 自制基于 centos7 的 中文支持带 openjdk 运行环境的底包 Dockerfile

创建 Dockerfile

mkdir -p /docker/dockerfile/centos7

cat > /docker/dockerfile/centos7/Dockerfile <<EOF
FROM centos:7
MAINTAINER blankhang <[email protected]>
LABEL version='1.0' description='centos7 with chinese lanugage and jdk8 and CST GMT+8 timezone support'

RUN yum install -y libXmu freetype kde-l10n-Chinese fontconfig && \
yum -y reinstall glibc-common && \
yum groupinstall "fonts" -y && fc-cache -fv && \
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone && \
yum install -y java-1.8.0-openjdk.x86_64 && \
yum clean all && rm -rf /var/cache/yum/*
EOF
创建构建推送镜像到私服脚本

可将 registry.aliyuncs.com/test/ 修改为你自己的私服地址

cat > /docker/dockerfile/centos7/build-and-push.sh << \EOF
#!/bin/bash

IMAGE_NAME=registry.aliyuncs.com/test/centos7-openjdk8

docker build -t ${IMAGE_NAME} .
docker push ${IMAGE_NAME}
EOF

# 脚本授权
chmod +x /docker/dockerfile/centos7/build-and-push.sh 

执行脚本 将会自动构建并推送镜像到私服

sh /docker/dockerfile/centos7/build-and-push.sh

然后 项目的 Dockerfile 就可以直接引用此包底了

节省大量的重复的底包构建时间

FROM registry.aliyuncs.com/test/centos7-openjdk8:latest

评论