一、准备打包所需基础镜像(euleros.tar)、jdk1.8(jdk-8u251-linux-x64.tar.gz)、jar(idea编译打包xxxbroker-1.0-SNAPSHOT.jar,myxxx-1.0-SNAPSHOT.jar)
二、导入镜像euleros.tar
docker load -i euleros.tar
三、创建Dockerfile文件
FROM euleros:2.2.5
MAINTAINER shinetech
COPY jdk1.8.0_251 /opt/jdk1.8.0_251
ADD mySSO-1.0-SNAPSHOT.jar /opt/myxxx-1.0-SNAPSHOT.jar
ADD ccebroker-1.0-SNAPSHOT.jar /opt/xxxbroker-1.0-SNAPSHOT.jar
ENV JAVA_HOME=/opt/jdk1.8.0_251
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
RUN echo -e \
"#!/bin/sh\n"\
"nohup java -jar /opt/mySSO-1.0-SNAPSHOT.jar > /opt/mysso.log &\n"\
>> /usr/bin/start.sh
RUN chmod +x /usr/bin/start.sh
EXPOSE 8088
EXPOSE 9999
CMD nohup sh -c "/usr/bin/start.sh && java -jar /opt/ccebroker-1.0-SNAPSHOT.jar"
四、编译并生成镜像 (. 表示当前路径)
docker build -t ccebroker:1.0 .
执行成功后会提示Successfullu...
五、查看生成的镜像
六、创建容器并运行
docker run -d -p 9999:9999 -p 8088:8088 --name ccebroker ccebroker:1.0
七、导出镜像
docker save -o ccebroker.tar ccebroker:1.0
docker save ccebroker:1.0 | gzip > ccebroker.tar.gz