Python 官方文档:入门教程 => 点击学习
目录1.场景2.编写SpringBoot项目打包上传linux服务器2.1将jar包和Docker放到同一个目录2.2编写dockerfile3.运行dockerfile4.查看镜像
stringboot - > Spring Boot .jar -> dockerfile---> run dokcerfile
-rw-r--r-- 1 root root 19514674 2月 27 22:48 myspringbootdocker.jar
[root@basenode springbootdocker]# pwd
/opt/springbootdocker
[root@basenode springbootdocker]#
1.需要注意的是 jar包名字不能有大写
2.Dockerfile 的文件名 首字母D 必须大写
[root@basenode springbootdocker]# vi Dockerfile
# 基础镜像使用java
FROM java:8
# 作者
MaiNTAINER wudl
# VOLUME 指定临时文件目录为/tmp,在主机/var/lib/docker目录下创建了一个临时文件并链接到容器的/tmp
VOLUME /tmp
# 将jar包添加到容器中并更名为zzyy_docker.jar
ADD myspringbootdocker.jar /myspringbootdocker.jar
# 运行jar包
RUN bash -c 'touch /myspringbootdocker.jar'
ENTRYPOINT ["java","-jar","/myspringbootdocker.jar"]
#暴露18088端口作为微服务
EXPOSE 18088
命令 docker build -t myspringbootdocker:1.6 .
[root@basenode springbootdocker]# docker build -t myspringbootdocker:1.6 .
Sending build context to Docker daemon 19.52MB
Step 1/7 : FROM java:8
8: Pulling from library/java
5040bd298390: Pull complete
fce5728aad85: Pull complete
76610ec20bf5: Pull complete
60170fec2151: Pull complete
e98f73De8f0d: Pull complete
11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete
bb9cdec9c7f3: Pull complete
Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d
Status: Downloaded newer image for java:8
---> d23bdf5b1b1b
Step 2/7 : MAINTAINER wudl
---> Running in 91aDDD3bc917
Removing intermediate container 91addd3bc917
---> 7982d20f4554
Step 3/7 : VOLUME /tmp
---> Running in 6973feea6ef5
Removing intermediate container 6973feea6ef5
---> c2feccd04de7
Step 4/7 : ADD myspringbootdocker.jar /myspringbootdocker.jar
---> fa79952fe484
Step 5/7 : RUN bash -c 'touch /myspringbootdocker.jar'
---> Running in f75bf573ec70
Removing intermediate container f75bf573ec70
---> 6d82fe109ae7
Step 6/7 : ENTRYPOINT ["java","-jar","/myspringbootdocker.jar"]
---> Running in 3fce2f523b70
Removing intermediate container 3fce2f523b70
---> 80ef7731c159
Step 7/7 : EXPOSE 18088
---> Running in 2d1179d0cfb4
Removing intermediate container 2d1179d0cfb4
---> 3f4e689e54db
Successfully built 3f4e689e54db
Successfully tagged myspringbootdocker:1.6
[root@basenode springbootdocker]#
[root@basenode springbootdocker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myspringbootdocker 1.6 3f4e689e54db 2 minutes aGo 682MB
Centosjava8 1.5 14fad190b338 4 weeks ago 801MB
Nacos/nacos-server v2.0.4 ea54f31c46e4 5 weeks ago 1.07GB
Tomcat latest fb5657adc892 2 months ago 680MB
Mysql 5.7 c20987f18b13 2 months ago 448MB
apache/incubator-doris build-env-latest cc924653f13d 2 months ago 4.24GB
apache/incubator-doris build-env-for-0.15.0 e568f7b2e1d8 3 months ago 3.54GB
docker run -d -p 18089:18088 3f4e689e54db
[root@basenode springbootdocker]# docker run -d -p 18089:18088 3f4e689e54db
5040141bd7d5700d8310a70309f940bb452656c0e909c6c6e138f7f6a9f65295
[root@basenode springbootdocker]#
到此这篇关于springboot运行到dokcer中 dockerfile的文章就介绍到这了,更多相关springboot运行dockerfile内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: springboot运行到dokcer中dockerfile的场景分析
本文链接: https://lsjlt.com/news/141158.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0