Dockerfile定义
FROM openjdk:8-jre-slim
WORKDIR /data/apps/xxl-job
COPY ./xxl-job-admin-2.3.0.jar /data/apps/xxl-job/xxl-job-admin-2.3.0.jar
COPY ./application.properties /data/apps/xxl-job/application.properties
ENV PARAMS=""
ENV JAVA_OPTS="-Xms256m -Xmx512m"
ENV TZ=PRC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS xxl-job-admin-2.3.0.jar $PARAMS"]
构建镜像命令(多架构)
docker build --build-arg ARCH=arm64 --build-arg OS=linux -t xuxueli/xxl-job-admin:2.3.0-arm64 -f Dockerfile .
docker build --build-arg ARCH=amd64 --build-arg OS=linux -t xuxueli/xxl-job-admin:2.3.0-amd64 -f Dockerfile .
运行&测试镜像
docker run -it \
-e PARAMS='--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=root --spring.datasource.password=123456' \
-p 8080:8080 \
-v ./logs:/data/applogs \
--name xxl-job-admin \
-d xuxueli/xxl-job-admin:2.3.0-arm64
推送镜像
docker push xuxueli/xxl-job-admin:2.3.0-arm64
docker push xuxueli/xxl-job-admin:2.3.0-amd64
创建manifest
docker manifest create xuxueli/xxl-job-admin:2.3.0 xuxueli/xxl-job-admin:2.3.0-arm64 xuxueli/xxl-job-admin:2.3.0-amd64 --amend
docker manifest annotate xuxueli/xxl-job-admin:2.3.0 xuxueli/xxl-job-admin:2.3.0-amd64 --os linux --arch amd64
docker manifest annotate xuxueli/xxl-job-admin:2.3.0 xuxueli/xxl-job-admin:2.3.0-arm64 --os linux --arch arm64
docker manifest push xuxueli/xxl-job-admin:2.3.0
制作docker-compose.yaml(进阶)
version: '3.3'
services:
xxl-job-admin:
image: xuxueli/xxl-job-admin:2.3.0-arm64
ports:
- "8080:8080"
environment:
PARAMS: '
--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
--spring.datasource.username=root
--spring.datasource.password=123456
'
volumes:
- ./logs:/data/applogs/xxl-job
使用docker-compose启动
docker-compose up