1. 提前准备好文件:
- jdk-8u202-linux-x64.rpm
- apache-maven-3.8.7
maven 3.8.7的文件准备; 按需注释掉maven https 0.0.0.0的安全限制
wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz
tar -zxvf ./apache-maven-3.8.7-bin.tar.gz
2. 编辑Dockerfile
vim Dockerfile
3. 源镜像amazonlinux:latest
# syntax=docker/dockerfile:1
FROM amazonlinux:latest
COPY jdk-8u202-linux-x64.rpm jdk-8u202-linux-x64.rpm
RUN rpm -ivh ./jdk-8u202-linux-x64.rpm
RUN rm -rf ./jdk-8u202-linux-x64.rpm
RUN mkdir -p /usr/local/maven/apache-maven-3.8.7
COPY ./apache-maven-3.8.7/ /usr/local/maven/apache-maven-3.8.7/
RUN ln -s /usr/local/maven/apache-maven-3.8.7/bin/mvn /usr/bin/mvn
4. 构建镜像
name the image as xxxxxxxxxxxxxxxxxxxxx
docker build --tag xxxxxxxxxxxxxxxxxxxxx .