发布部署文档,重启不需要重新构建镜像

jian436 2022-08-01 15:17:28

效果:将更新文件放到对应文件目录,重启容器就能运行更新的程序,不需要重新构建容器。
docker-compose.yaml


  thinglinks-auth:
    container_name: thinglinks-auth
    build:
      context: ./thinglinks/auth
      dockerfile: Dockerfile
    ports:
      - "19200:19200"
    volumes:
      - ./thinglinks/lib:/home/iotdocker/thinglinks/lib
      - ./thinglinks/auth/jar:/home/iotdocker/thinglinks/auth/jar
      - ./thinglinks/auth/logs:/home/iotdocker/thinglinks/logs/thinglinks-auth

dockerfile


# 基础镜像
FROM  openjdk:8-jre
# author
MAINTAINER thinglinks

# 挂载目录
# VOLUME /home/iotdocker/thinglinks
# 创建目录
RUN mkdir -p /home/iotdocker/thinglinks
# 指定路径
WORKDIR /home/iotdocker/thinglinks
# 复制jar文件到路径
COPY ./jar/thinglinks-auth-1.0.0.RELEASE.jar /home/iotdocker/thinglinks/auth/jar/thinglinks-auth-1.0.0.RELEASE.jar
# 启动认证服务
ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "./auth/jar/thinglinks-auth-1.0.0.RELEASE.jar"]

下面是在 /home/iotdocker/thinglinks 目录下运行,这个目录下面有docker-compose.yaml这个文件

# root @ xx in /home/iotdocker/thinglinks [15:08:43] 
$  docker-compose up -d thinglinks-auth
Sending build context to Docker daemon  162.5kB
Step 1/6 : FROM  openjdk:8-jre
 ---> 26ac3f63d29f
Step 2/6 : MAINTAINER thinglinks
 ---> Running in c881f7898f69
Removing intermediate container c881f7898f69
 ---> e1d7c2505428
Step 3/6 : RUN mkdir -p /home/iotdocker/thinglinks
 ---> Running in d5541ff6ff79
Removing intermediate container d5541ff6ff79
 ---> e80f8be9ea02
Step 4/6 : WORKDIR /home/iotdocker/thinglinks
 ---> Running in f17ffb81ecfc
Removing intermediate container f17ffb81ecfc
 ---> 726c6f899fda
Step 5/6 : COPY ./jar/thinglinks-auth-1.0.0.RELEASE.jar /home/iotdocker/thinglinks/auth/jar/thinglinks-auth-1.0.0.RELEASE.jar
 ---> f83b0234b9c5
Step 6/6 : ENTRYPOINT ["java", "-Xmx400m", "-Xms400m", "-Xmn150m", "-Xss1024k", "-jar", "./auth/jar/thinglinks-auth-1.0.0.RELEASE.jar"]
 ---> Running in fd5b15cb8de1
Removing intermediate container fd5b15cb8de1
 ---> a08267619fd5
Successfully built a08267619fd5
Successfully tagged iotdocker_thinglinks-auth:latest

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
[+] Running 1/1
 ⠿ Container thinglinks-auth  Started  

启动完成可以看到宿主机目录/home/iotdocker/thinglinks/auth/logs出现日志文件

...全文
570 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
绝学 11-22
  • 打赏
  • 举报
回复

你自己测过了吗

todostudy 10-12
  • 打赏
  • 举报
回复

有产品操作文档吗,下发命令给设备都不知道怎么操作

相关推荐
发帖
ThingLinks社区

303

社区成员

ThingLinks物联网一体化平台社区 版本将持续迭代更新,支持商业二开; 欢迎你分享物联网及平台相关技术文档;
物联网能源开源 企业社区
社区管理员
  • xiaonannet
  • jian436
  • 很久是多久
加入社区
帖子事件
创建了帖子
2022-08-01 15:17
社区公告

ThingLinks物联网一体化平台社区

https://gitee.com/mqttsnet/thinglinks

https://github.com/mqttsnet/thinglinks