下载alpine系统镜像

[root@docker~]# docker pull alpine:3.14

 

准备alpine镜像源文件

[root@docker~]# mkdir alpine
[root@docker alpine]# vim repositories
http://mirrors.aliyun.com/alpine/v3.14/main                                                                                          
http://mirrors.aliyun.com/alpine/v3.14/community

 

 编写Dockerfile文件 

 

FROM alpine:3.14      #指定基础镜像
LABEL maintainer="quhongzhi1212@163.com"   #作者信息
COPY repositories /etc/apk/repositories    #拷贝镜像源文件
RUN apk update && apk --no-cache add iotop gcc libgcc libc-dev libcurl libc-utils pcre-dev zlib-dev libnfs make pcre pcre2 zip unzip 
net-tools pstree wget libevent libevent-dev iproute2  openjdk8-jre-base      #安装JDK及相关软件包

 构建基于alpine的JDK镜像

[root@docker alpine]# docker build -t alpine-jdk:v1.8 .

[root@docker alpine]# docker images alp*
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
alpine-jdk   8u212     d8be19eb2843   About a minute ago   598MB
alpine       3.14      021b3423115f   2 weeks ago          5.6MB

 

 JDK镜像构建tomcat 8 Base镜像 

下载tomcat安装包

[root@docker ~]# mkdir tomcat &&cd tomcat
[root@docker tomcat]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.70/bin/apache-tomcat-8.5.70.tar.gz

 

 编写Dockerfile文件 

 

FROM alpine-jdk:v1.8
LABEL maintainer="quhongzhi1212@163.com>"
ENV TZ "Asia/Shanghai"
ENV LANG en_US.UTF-8
ENV TERM xterm
ENV TOMCAT_MAJOR_VERSION 8
ENV TOMCAT_MINOR_VERSION 8.5.70
ENV CATALINA_HOME /apps/tomcat
ENV APP_DIR ${CATALINA_HOME}/webapps
RUN mkdir /apps
ADD apache-tomcat-8.5.70.tar.gz /apps                                                                                                
RUN ln -s /apps/apache-tomcat-8.5.70 /apps/tomcat
EXPOSE 8080 8009
ENTRYPOINT ["/apps/tomcat/bin/catalina.sh","run"]

 

 

 构建基于alpine-JDK的tomcat镜像

[root@docker tomcat]# docker build -t tomcat-base:v8.5.70 .
[root@docker tomcat]# docker images tomcat-base
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
tomcat-base   v8.5.70   1ac959e3285a   6 minutes ago   613MB

 

创建tomcat容器

[root@docker tomcat]# docker run -d -p 8080:8080 tomcat-base:v8.5.70

 

测试验证

基于alpine制作tomcat镜像_docker