标签:container grep bsp 字符 目录 ble action running -o
1、在IDEA中通过maven package得到watchman-1.5.0-SNAPSHOT.jar,将其scp到baisheng1本地;
2、查看dbaservice2所在的pod
kubectl get po -owide | grep dbaservice2
结果: dbaservice-server-dbaservice2-6f4bb88df7-9p5zr 1/1 Running 0 23m 172.26.0.73 baisheng1
3、执行下面命令获取该pod的配置信息,从中找到容器ID(Container ID):是结果中"//"后面的长字符串
kubectl describe pods dbaservice-server-dbaservice2-6f4bb88df7-9p5zr
4、使用docker命令导入jar包到容器根目录(下面的长字符串是pod中的容器ID:Container ID)
docker cp watchman-1.5.0-SNAPSHOT.jar da2c9b6af26e0f25300d245261569ae64603573b0fdbcfd1cc17d14be0197615:/
5、进入该pod,先删除掉原来的watchman.jar,修改刚刚拷贝进来的watchman-1.5.0-SNAPSHOT.jar文件名为watchman.jar(因为java -jar启动命令定义的是启动watchman.jar,故要更名)
(1)进入该pod:kubectl exec -ti dbaservice-server-dbaservice2-6f4bb88df7-9p5zr -- bin/sh
(2)删除原来的jar包:rm -r watchman.jar
(3)更名:mv watchman-1.5.0-SNAPSHOT.jar watchman.jar
6、执行exit退出该pod
7、执行docker commit [container_id] [image_repo]:[image_tag],将container的修改更新到对应的image上
这里的container_id就是上面的容器ID,image_repo是本地的“transwarp/dbaservice“,image_tag是自定义的”i18n“
8、执行docker tag transwarp/dbaservice:i18n baisheng3:5000/transwarp/dbaservice:i18n (用来在远程仓库创建TAG)
9、执行docker push baisheng3:5000/transwarp/dbaservice:i18n (push到远程仓库)
10、执行kubectl set image deployment/dbaservice-server-dbaservice2 dbaservice-server-dbaservice2=baisheng3:5000/transwarp/dbaservice:i18n
就可将新的image打进该pod中,然后重启pod即可。
新建一个文件夹,将需要替换的JAR包,放在此文件内
在文件内新建一个Dockerfile
vi Dockerfile |
根据所要替换的JAR包在image中的位置,编写Dockerfile
FROM 172.16 . 1.99 /postcommit/inceptor:master- 2019 - 11 - 19 - 02 - 19 - 35 -966260e9ad266e36df2cf968e0512f8594615072 // 1. 指定从哪个镜像开始改动,这里是inceptor master的某一个postcommit build RUN rm -f /usr/lib/inceptor/inceptor-engine*.jar /usr/lib/inceptor/lib/inceptor-core*.jar /usr/lib/inceptor/lib/inceptor-base*.jar // 2. 删除镜像内的JAR包,这一步不是必须的 COPY inceptor-engine-master-SNAPSHOT.jar /usr/lib/inceptor/ COPY inceptor-core-master-SNAPSHOT.jar inceptor-base-master-SNAPSHOT.jar /usr/lib/inceptor/lib/ // 3. 将新JAR包(一定要在同文件夹下)复制到镜像内相应位置 |
所有文件就位后,是这个样子
[root@baisheng3 nucleon] # pwd /home/yewu/docker/nucleon [root@baisheng3 nucleon] # ll 总用量 26920 -rw-r--r-- 1 root root 426 11月 19 15:13 Dockerfile -rw-r--r-- 1 root root 371264 11月 20 20:57 inceptor-base-master-SNAPSHOT.jar -rw-r--r-- 1 root root 14857951 11月 20 20:57 inceptor-core-master-SNAPSHOT.jar -rw-r--r-- 1 root root 11572363 11月 20 20:57 inceptor-engine-master-SNAPSHOT.jar |
在这个文件内运行docker build, 其中-t 指定image名,不写的话,后面只能用IMAGE ID(hash)做tag操作
docker build -t <image_name_and_tag> ./ |
docker push至repository
docker push <image_name_and_tag> |
对于需要更新的pod,直接删除。自动重启后就会拉取最新image覆盖本地同名image
kubectl delete po $(kubectl get po | grep inceptor12 | awk ‘{print $1}‘ ) |
这句的意思是 找到所有名字带inceptor12的pod并删除
TL;DR
Dockerfile备好,文件放好,直接一次执行,全部办妥:(示例)
docker build -t baisheng3: 5000 /transwarp/inceptor:nucleon ./;docker push baisheng3: 5000 /transwarp/inceptor:nucleon;kubectl delete po $(kubectl get po | grep inceptor12 | awk ‘{print $1}‘ ) |
参考链接:TDH 5.0 rubik换包
https://docs.docker.com/engine/reference/commandline/tag/
标签:container grep bsp 字符 目录 ble action running -o
原文地址:https://www.cnblogs.com/renyang/p/12066825.html