好处是,如果配置文件里面的信息改变了,比如访问地址变了,可以修改配置文件后重新制作镜像,不用改java代码重新打jar包
Dockerfile文件内容:
FROM openjdk:8u102 RUN echo 'Asia/Shanghai' >/etc/timezone COPY ./app /add/app/ WORKDIR /add/app ENTRYPOINT ["java","-Xms512m","-Xmx512m","-Xmn200m","-Xss256k","-jar","geo-search-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"] EXPOSE 20089
进入/mydata/images/geo-search目录,然后运行如下命令制作镜像
docker build -t geo-search .
启动镜像
docker run --name geo-search -v /home/tony/docker/upfiles:/add/upfiles -d -p 20089:20089 geo-search