-
拉取java:8-jdk-alpine镜像作为基础镜像
docker pull java:8-jdk-alpine
-
编写Dockerfile
mkdir /root/Dockerfile cd /root/Dockerfile
vim repositories
powershell
http://mirrors.aliyun.com/alpine/v3.8/main/
http://mirrors.aliyun.com/alpine/v3.8/community/
vim Dockerfile
powershell
FROM java:8-jdk-alpine
COPY repositories /etc/apk/repositories
RUN apk update && apk add tzdata
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
-
构建镜像
docker build -t java:8 .
-
运行测试
docker run --rm -it java:8 sh
4.1. 测试时区
powershell
/ # date
Thu Nov 16 10:01:57 CST 2023
4.1. 测试是否能安装软件
powershell
/ # apk add --update wget
fetch http://mirrors.aliyun.com/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.aliyun.com/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
WARNING: This apk-tools is OLD! Some packages might not function properly.
(1/3) Installing libressl2.7-libcrypto (2.7.5-r0)
(2/3) Installing libressl2.7-libssl (2.7.5-r0)
(3/3) Installing wget (1.20.3-r0)
Executing busybox-1.24.2-r13.trigger
Executing ca-certificates-20161130-r0.trigger
OK: 147 MiB in 39 packages