Docker Review - Docker 部署 Spring Boot 项目
【摘要】
文章目录
Pre编辑DockerfileDockerfile 构建镜像运行镜像测试
Pre
随手搞个spring boot的演示项目 ,确保能访问
编辑Dockerf...
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 ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
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
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
运行镜像
[root@VM-0-7-centos ~]# docker images | grep bootdemo
bootdemo latest 3f0c42435a0c 54 seconds ago 672MB
[root@VM-0-7-centos ~]#
- 1
- 2
- 3
- 4
- 5
[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 ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
测试
文章来源: artisan.blog.csdn.net,作者:小小工匠,版权归原作者所有,如需转载,请联系作者。
原文链接:artisan.blog.csdn.net/article/details/120818453
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)