拉取jdk镜像文件
# docker pull huanwei/alpine-oraclejdk8
创建文件夹编写Dockerfile文件
# mkdir docker
# vi Dockerfile
FROM docker.io/huanwei/alpine-oraclejdk8 MAINTAINER djl "djl@cnbisoft.com" ENV REGISTRY_SERVER_USERNAME test ENV REGISTRY_SERVER_PASSWORD test ENV CONFIG_SERVER_USERNAME user ENV CONFIG_SERVER_PASSWORD 123 ENV RABBITMQ_SERVER_USERNAME test ENV RABBITMQ_SERVER_PASSWORD root ENV MYSQL_SERVER_USERNAME root ENV MYSQL_SERVER_PASSWORD 123456 ENV REDIS_SERVER_PASSWORD 123456 ENV MONITOR_SERVER_USERNAME user ENV MONITOR_SERVER_PASSWORD 123 ENV REDIS_SERVER_USERNAME EXPOSE 80 8888 8889 6004 6005 5000 6006 8000 9100 8761 ENTRYPOINT ["java","-D java.security.egd=file:/dev./urandom","-jar","/data/app.jar"]
构建镜像
# docker build -t jdk1.8:v1 .
运行容器
# docker run -itd -p 5000:5000 -v /home/tenancy/tenancy.jar:/data/app.jar --name tenancy --add-host registry:192.168.2.236 --add-host config:192.168.2.236 --add-host api-gateway:192.168.2.236 --add-host cnbi-redis:192.168.2.236 --add-host cnbi-rabbitmq:192.168.2.232 --add-host cnbi-mysql:192.168.2.240 jdk1.8:v1
参考博客:
https://www.cnblogs.com/zhangwufei/p/9034997.html