• docker 停止服务 部署服务


    //显示所有容器 一个容器只管理一个服务 即使容器挂掉也不会影响其他容器的服务 做到业务之间不影响
    root@river-NUC8i7HNK:/# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e8cfcbe6a280 etl-online:1.0 "java -Djava.securit…" About an hour ago Up About an hour 0.0.0.0:8070->8070/tcp etl-online_etl-online_1 377db9b29f0f web:3.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:30003->30003/tcp web_power_1 cf44fc608372 power:2.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:8000->30001/tcp power_power_1 4f951b13e170 etl:2.0 "java -Djava.securit…" 2 weeks ago Up 2 weeks 0.0.0.0:8090->8090/tcp etl_power_1 524d7d7ae738 redis:4 "docker-entrypoint.s…" 4 weeks ago Up 4 weeks 0.0.0.0:6379->6379/tcp redis_redis_1 //停止id为e8的服务
    root@river
    -NUC8i7HNK:/# docker stop e8 e8
    //显示所有容器 (包括已停止 和 正在运行的 所有容器)
    //可以看到刚刚停掉的容器e8依然在 root@river
    -NUC8i7HNK:/# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e8cfcbe6a280 etl-online:1.0 "java -Djava.securit…" About an hour ago Exited (143) 35 seconds ago etl-online_etl-online_1 377db9b29f0f web:3.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:30003->30003/tcp web_power_1 cf44fc608372 power:2.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:8000->30001/tcp power_power_1 ac631c839c3f web:2.0 "java -Djava.securit…" 13 days ago Exited (143) 11 days ago stoic_brahmagupta 4f951b13e170 etl:2.0 "java -Djava.securit…" 2 weeks ago Up 2 weeks 0.0.0.0:8090->8090/tcp etl_power_1 524d7d7ae738 redis:4 "docker-entrypoint.s…" 4 weeks ago Up 4 weeks 0.0.0.0:6379->6379/tcp redis_redis_1 //删掉容器 e8
    root@river
    -NUC8i7HNK:/# docker rm e8 e8
    //显示所有容器 刚刚被删掉的e8容器已经不在 root@river
    -NUC8i7HNK:/# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 377db9b29f0f web:3.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:30003->30003/tcp web_power_1 cf44fc608372 power:2.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:8000->30001/tcp power_power_1 ac631c839c3f web:2.0 "java -Djava.securit…" 13 days ago Exited (143) 11 days ago stoic_brahmagupta 4f951b13e170 etl:2.0 "java -Djava.securit…" 2 weeks ago Up 2 weeks 0.0.0.0:8090->8090/tcp etl_power_1 524d7d7ae738 redis:4 "docker-entrypoint.s…" 4 weeks ago Up 4 weeks 0.0.0.0:6379->6379/tcp redis_redis_1 //显示所有镜像
    root@river
    -NUC8i7HNK:/# docker images REPOSITORY TAG IMAGE ID CREATED SIZE etl-online 1.0 ea5d3b622b9a About an hour ago 129MB web 3.0 827e32b2d8d0 11 days ago 148MB power 2.0 e724aa1ca532 11 days ago 144MB web 2.0 f92b3295b202 13 days ago 148MB etl 2.0 af8defc8f406 2 weeks ago 142MB redis 4 29c39fa179d6 8 weeks ago 89.2MB openjdk 8-jdk-alpine a3562aa0b991 5 months ago 105MB //删除 镜像名为ea的镜像
    root@river
    -NUC8i7HNK:/# docker rmi ea Untagged: etl-online:1.0 Deleted: sha256:ea5d3b622b9a5c8e2a5dfaf1bf7d80b8dcd57276cc60f7ee43e8ef59b9473d5f Deleted: sha256:d5c6bc729e27c1a880841e1fea67cff7afaced7c6dea0f91a40ead7498063ae7 Deleted: sha256:e07da659170a89263aa49421bfae3a650e37e07fc5ab075929a2b93dbb1a0a80 Deleted: sha256:27943a63846ab43d150b7b1a3ce65214863cf317cf1e54a019de1ee393553412 Deleted: sha256:fc0e8cde49b25fdc8d4c3b650aa122ad2383ad7f91bc3845357c38e496e7cedc Deleted: sha256:99e6f0a38f9e9f9c57aa74d811232b620815b4ccfe7870be3088ae2ad469a3a0 root@river-NUC8i7HNK:/#

    上述过程为 停止服务 停止服务前 要先删容器 再删镜像

    下述过程为 上传jar包 在docker中启动该服务(jar包)

    //rz 上传jar包到此处 查看如下 etl-online-2.0-SNAPSHOT.jar
    root@river-NUC8i7HNK:/package/etl-online# ll 总用量 24064 drwxr-xr-x 2 root root 4096 10月 10 17:24 ./ drwxr-xr-x 3 root root 4096 10月 10 16:22 ../ -rw-r--r-- 1 root root 249 10月 10 16:25 docker-compose.yml -rw-r--r-- 1 root root 264 10月 10 16:24 Dockerfile -rw-r--r-- 1 root root 24622035 10月 10 17:19 etl-online-2.0-SNAPSHOT.jar
    //一键启动命令 docker-compose up -d (先生成镜像再生成容器)
    root@river-NUC8i7HNK:/package/etl-online# docker-compose up -d
    //下面为启动成功的日志 Building etl
    -online Step 1/6 : FROM openjdk:8-jdk-alpine ---> a3562aa0b991 Step 2/6 : VOLUME /tmp ---> Using cache ---> 8357f856edc2 Step 3/6 : ADD etl-online-2.0-SNAPSHOT.jar app.jar ---> 8f2af2b3e46a Step 4/6 : ENTRYPOINT ["java","-Djava.security.egd=fele:/dev/./urandom","-jar","/app.jar"] ---> Running in 61869b4bc3d3 Removing intermediate container 61869b4bc3d3 ---> e1acb02e507b Step 5/6 : ENV TZ=Asia/Shanghai ---> Running in 4111226fd387 Removing intermediate container 4111226fd387 ---> fce921d488aa Step 6/6 : RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ---> Running in 49fb66f0821f Removing intermediate container 49fb66f0821f ---> d3c32537e84e Successfully built d3c32537e84e Successfully tagged etl-online:1.0 WARNING: Image for service etl-online was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. Creating etl-online_etl-online_1 ... done
    //查看正在运行的容器 etl-online已在运行中 up 7 seconds root@river
    -NUC8i7HNK:/package/etl-online# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1c0d012c9ba4 etl-online:1.0 "java -Djava.securit…" 9 seconds ago Up 7 seconds 0.0.0.0:8070->8070/tcp etl-online_etl-online_1 377db9b29f0f web:3.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:30003->30003/tcp web_power_1 cf44fc608372 power:2.0 "java -Djava.securit…" 11 days ago Up 11 days 0.0.0.0:8000->30001/tcp power_power_1 4f951b13e170 etl:2.0 "java -Djava.securit…" 2 weeks ago Up 2 weeks 0.0.0.0:8090->8090/tcp etl_power_1 524d7d7ae738 redis:4 "docker-entrypoint.s…" 4 weeks ago Up 4 weeks 0.0.0.0:6379->6379/tcp redis_redis_1 root@river-NUC8i7HNK:/package/etl-online#

    docker-compose.yml

    version: '2'
    services:
     etl-online:
      image: etl-online:1.0   指定 镜像名称
      build: .
      ports:
             - "8070:8070"   端口映射
      extra_hosts:
             - "自定义:192.168.3.118"  ip映射
             - "自定义:192.168.3.118"
             - "自定义:192.168.3.118"

    Dockerfile

    FROM openjdk:8-jdk-alpine
    VOLUME /tmp
    ADD etl-online-2.0-SNAPSHOT.jar app.jar   //指定jar包名字 启动容器会根据这里的名字去找jar包
    ENTRYPOINT ["java","-Djava.security.egd=fele:/dev/./urandom","-jar","/app.jar"]
    ENV TZ=Asia/Shanghai  //时区
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    ~                                                                                
  • 相关阅读:
    关于oralce字符集问题(复制别人的,纯属自己学习)
    Linux下oracle11gR2系统安装到数据库建立配置及最后oracle的dmp文件导入一站式操作记录
    Linux下部署ASP.NET服务连接oracle遇到的问题记录
    前端金钱分转元,元转分精度问题解决
    vue-element的form表单显示图片
    vue页面刷新技巧--(v-if指令)以及vue动态设置css属性
    vue后端获取的数据无法进行双向数据绑定
    Vue实现勾选框全选和局部选择功能
    VUE/jQuery生成二维码扫描跳转地址
    uni-app之数据状态改动后页面不刷新踩坑
  • 原文地址:https://www.cnblogs.com/s6-b/p/11649710.html
Copyright © 2020-2023  润新知