博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
docker 部署SpringBoot项目
阅读量:3867 次
发布时间:2019-05-23

本文共 976 字,大约阅读时间需要 3 分钟。

1、拉取tomcat镜像

docker pull java:8

2、通过上传需要部署的zip解压 / 从git上拉取springboot项目

3、在上个步骤创建的工作目录下创建Dockerfile文件。将zip包解压,和Dockerfile文件放在同一目录下。Dockerfile文件内容如下:

from java:8ENV LANG C.UTF-8ENV TZ=Asia/ShanghaiENV JAVA_OPTS=" -Dspring.config.location=/hello/application.properties"RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezoneADD hello.zipRUN unzip hello.zipRUN chmod +x /hello/bin/start.shRUN chmod +x /hello /bin/stop.shCMD cd /hello /bin/&&./start.sh

4、创建镜像(注:-t 表示为该镜像起名称,另外,构建命令后面有个英文实心点,表示当前目录。)

docker build -t hello

5、通过docker images可以看到该镜像已经创建成功了

docker images | grep hello

6、运行自己的镜像(注: -d:表示在后台运行该镜像,按ctrl+C不会终止该程序;-p:表示指定本机的端口对应容器中的端口。-it表示以交互模式运行容器并分配伪终端。uap-service项目内置了一个tomcat容器,在其application.properties配置文件中server.port=8080。若设置server.port=xxx,则命令相应位置为30803:xxx)(打开伪终端,进去容器)

docker run -p 30803:8080 hello

7、docker镜像导出,tar镜像包可以拷贝到其他机器docker环境中加载

docker save hello -o hello.tar

8、docker镜像加载

docker load -i hello.tar

9、测试示例

http://ip:30803/hello

转载地址:http://dcemn.baihongyu.com/

你可能感兴趣的文章
Hadley Wickham:一个改变了R的人
查看>>
glibc 指导委员会解散声明
查看>>
Linux创始者托瓦兹谈及IoT --「安全在其次」
查看>>
传感器数据分析(Sensor Data Analytics)是什么?
查看>>
智能硬件开发如何选择低功耗MCU?
查看>>
阿里感悟(十)如何写好简历
查看>>
阿里感悟(十一)如何准备面试
查看>>
软件架构入门
查看>>
80 多个 Linux 系统管理员必备的监控工具
查看>>
OOD的原则
查看>>
Tool to trace local function calls in Linux
查看>>
Linux 下查询 DNS 服务器信息
查看>>
ulimit 里的 file size 的 block 单位是多少?
查看>>
linux下查看端口对应的进程
查看>>
将 gdb 用作函数跟踪器 (Function Tracer)
查看>>
原 GCC一些有用的技巧
查看>>
yum 变量追加的方法
查看>>
2倍速的下一代Bluetooth,「Bluetooth 5」发布
查看>>
Top 10 “Yum” installables to be productive as a developer on Red Hat Enterprise Linux
查看>>
[小技巧] Vim 如果去除 “existing swap file” 警告
查看>>