Docker Review - Docker 部署 Spring Boot 项目
Posted 小小工匠
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker Review - Docker 部署 Spring Boot 项目相关的知识,希望对你有一定的参考价值。
Pre
随手搞个spring boot的演示项目 ,确保能访问
编辑Dockerfile
[root@VM-0-7-centos ~]# cat bootDockerfile
FROM java:8
COPY *.jar /helloboot-0.0.1-SNAPSHOT.jar
CMD ["--server.port=6666"]
EXPOSE 6666
ENTRYPOINT ["java","-jar","/helloboot-0.0.1-SNAPSHOT.jar"]
[root@VM-0-7-centos ~]#
Dockerfile 构建镜像
[root@VM-0-7-centos ~]# docker build -f bootDockerfile -t bootdemo .
Sending build context to Docker daemon 723.6MB
Step 1/5 : FROM java:8
---> d23bdf5b1b1b
Step 2/5 : COPY *.jar /helloboot-0.0.1-SNAPSHOT.jar
---> 015febc1454b
Step 3/5 : CMD ["--server.port=6666"]
---> Running in f705ab3f5f02
Removing intermediate container f705ab3f5f02
---> f608f250f0db
Step 4/5 : EXPOSE 6666
---> Running in c1db7f8a530a
Removing intermediate container c1db7f8a530a
---> de2f50692242
Step 5/5 : ENTRYPOINT ["java","-jar","/helloboot-0.0.1-SNAPSHOT.jar"]
---> Running in f6fc8d988e21
Removing intermediate container f6fc8d988e21
---> 3f0c42435a0c
Successfully built 3f0c42435a0c
Successfully tagged bootdemo:latest
运行镜像
[root@VM-0-7-centos ~]# docker images | grep bootdemo
bootdemo latest 3f0c42435a0c 54 seconds ago 672MB
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker run -d -p 7777:6666 --name artisanBoot bootdemo
0d4d248db761a6a78234fc20d303e52fa96d3dc7d0292af871f34fcc310e30c4
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d4d248db761 bootdemo "java -jar /helloboo…" 6 seconds ago Up 5 seconds 0.0.0.0:7777->6666/tcp, :::7777->6666/tcp artisanBoot
3eab753d9573 portainer/portainer "/portainer" 11 days ago Up 11 days 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
测试
以上是关于Docker Review - Docker 部署 Spring Boot 项目的主要内容,如果未能解决你的问题,请参考以下文章
Docker Review - Docker 概念 & 入门篇
Docker Review - docker 容器 常用命令
Docker Review - 使用docker file 构建镜像