本人在工作中遇到了需要在docker查看jar这种操作,查看了许多资料,终于还是找到了
引言
在docker中查看jar的情况分为两种,一种是使用k8s的情况,一种不使用的情况,下面两种情况都会介绍
一、使用k8s查看
查看镜像
sudo docker images | grep 镜像名字
查看镜像的名字
docker inspect 镜像ID
内容一般都是
[
{
"Id": "sha256:bd95813096bd754b657fb7e531e3b86075ccf4388df5b452a819919ff00c91c2",
"RepoTags": [
"vvp-gateway:2.6.3_simon"
],
"RepoDigests": [],
"Parent": "sha256:59250f7815884db8ace5b956946370e8924ac74ad12acb922eb4431ad477418c",
"Comment": "",
"Created": "2022-07-11T07:12:46.084025129Z",
"Container": "cfca40ed3f7bb18674c6a2fcf0f78267517de6268c6d6bfddfc8c380fb33818d",
"ContainerConfig": {
"Hostname": "cfca40ed3f7b",
"Domainname": "",
"User": "root",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"JAVA_HOME=/usr/local/openjdk-11",
"LANG=C.UTF-8",
"JAVA_VERSION=11.0.15"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"java\" \"-Xdebug\" \"-agentlib:jdwp=transport=dt_socket,server=y,address=0.0.0.0:8899,suspend=n\" \"-XX:MaxRAMPercentage=50.0\" \"-XX:MaxMetaspaceSize=256m\" \"-Djava.security.egd=file:/dev/./urandom\" \"-cp\" \"/vvp/app:/vvp/app/lib/*\" \"com.ververica.platform.gateway.GatewayApplication\"]"
],
"Image": "sha256:59250f7815884db8ace5b956946370e8924ac74ad12acb922eb4431ad477418c",
"Volumes": {
"/vvp/data": {},
"/vvp/etc": {},
"/vvp/secrets": {}
},
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "Ververica <platform@ververica.com>"
}
},
"DockerVersion": "20.10.5",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "root",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"JAVA_HOME=/usr/local/openjdk-11",
"LANG=C.UTF-8",
"JAVA_VERSION=11.0.15"
],
"Cmd": [
"java",
"-Xdebug",
"-agentlib:jdwp=transport=dt_socket,server=y,address=0.0.0.0:8899,suspend=n",
"-XX:MaxRAMPercentage=50.0",
"-XX:MaxMetaspaceSize=256m",
"-Djava.security.egd=file:/dev/./urandom",
"-cp",
"/vvp/app:/vvp/app/lib/*",
"com.ververica.platform.gateway.GatewayApplication"
],
"Image": "sha256:59250f7815884db8ace5b956946370e8924ac74ad12acb922eb4431ad477418c",
"Volumes": {
"/vvp/data": {},
"/vvp/etc": {},
"/vvp/secrets": {}
},
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {
"maintainer": "Ververica <platform@ververica.com>"
}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 919299037,
"VirtualSize": 919299037,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/cc946e03217e4171399be855e56505bb037276d062c2829beea93d77f43cfaf6/diff:/var/lib/docker/overlay2/6b0a352106f128579123a45e3991b9f2492994d435180b3ca630b022f7cde088/diff:/var/lib/docker/overlay2/29ccfa6c76844dc9f104eabbf2c0e4db32a040ebfa3691078f9e751ea5a7d891/diff:/var/lib/docker/overlay2/d3eda21c53fad143abc5981dfccfac0ed33f5a2e71d3a78d9ca22ea3a6243c89/diff:/var/lib/docker/overlay2/6f336ec260b8060e77e268412246b8ecbf8a3ccbe025422dacf341337228793e/diff:/var/lib/docker/overlay2/d73a8b39b5bb63ba313669bab84d6a15378bd327944e4a43519fb8080b6e2fab/diff:/var/lib/docker/overlay2/568f3a48847e451e5482ffa75b65eff42d46b6eabe20371529379dcc79d528fb/diff:/var/lib/docker/overlay2/85feabbee50004762db71400d79ee1213b6bd580a949f628c765f3c29f7b5dd3/diff:/var/lib/docker/overlay2/76336ac57ecea887d8e5743c5897618a6398a609f9936ae7be811a2c45aad847/diff:/var/lib/docker/overlay2/db8d96c0e03b7632ee96077360103a053b88a04c95323ea6b8d612ecc918b78e/diff:/var/lib/docker/overlay2/41c62e7cf81c95bc8b77e6ce2677ded8448722b1fdb72ff9db395db7537fce8c/diff:/var/lib/docker/overlay2/35b917ac3d4b14291f8459e2ca01da3d016750b0586d7d1e412034340fe0f686/diff:/var/lib/docker/overlay2/769a1d6b4fd308283f55d7dea89c0bf375997560f85115a167b7528d26c3f256/diff:/var/lib/docker/overlay2/d8d20b6d384247cc05a7e1c1c4b0011f580ff0f01b0c1a0506420d7497dae89c/diff",
"MergedDir": "/var/lib/docker/overlay2/8a1defde1405c4ad9ee22830f3dac0bab42a492cbb55109364f3e968db3eab30/merged",
"UpperDir": "/var/lib/docker/overlay2/8a1defde1405c4ad9ee22830f3dac0bab42a492cbb55109364f3e968db3eab30/diff",
"WorkDir": "/var/lib/docker/overlay2/8a1defde1405c4ad9ee22830f3dac0bab42a492cbb55109364f3e968db3eab30/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:9c1b6dd6c1e6be9fdd2b1987783824670d3b0dd7ae8ad6f57dc3cea5739ac71e",
"sha256:13a34b6fff7804cf7f6e8f52a4cf25ceb2e32fc35a6f39e8158074c64831ebf0",
"sha256:8da60230c8c21a305a0b1871ea654b3a68ace50520397bd46b8b647c6e0891c4",
"sha256:f93bb772c4958617a803266969a338094cb73511c18605d87f53b1b2cfadc7b0",
"sha256:af70cff76a6274cc87e5a2f1c6c1fc6554524adf407fa94e387292d91b808d39",
"sha256:4503e1661bd9fe4381f37dd8c9960ef4301f387c88e6d1582922cccd0544d03e",
"sha256:690041a64b809a889f8e5e2ec9eda4300fbf76dfd488b8ee334eea3ced9ac7a3",
"sha256:f346876b3ef523394c2d0473501a50392d1df530daf0bd70d351830c782ccba3",
"sha256:620e3c5d227e2b96f1205ead77b84be11b239adf387d7b7e83c6cd4a508431aa",
"sha256:9b33a349b1c75a9040b5a8e277c0e0a535a87ba6fa87861268280f9862f8803d",
"sha256:6f55434bbaa3b9d42d629ce6ac1c0eba4214b835cdb7b3c5c74deae69a5c5436",
"sha256:8a9739c65869fd51708ba2ab262469b6b6d54f9576a924c89a852c26e8125c7b",
"sha256:cfe58338cf6bc3ed59ab76b731315e9d47ab96e8b8f4c84a501ce709e18930e0",
"sha256:57e0cc2daa9243c201289f7c677c40e1f45bc2f17023795ef7a8ef45f147d796",
"sha256:095b3833d28e6e3049512b7c588025cdb34fbf08c0de67cbd8e818714ab5b4c5"
]
},
"Metadata": {
"LastTagTime": "2022-07-11T15:12:46.143347824+08:00"
}
}
]
一版jar包都是在UpperDir中
进入到对应的目录中
sudo cd /var/lib/docker/overlay2/8a1defde1405c4ad9ee22830f3dac0bab42a492cbb55109364f3e968db3eab30/diff
在目录中可能会看到你项目的目录,也可能会直接就看到了jar包了,这个看你当时的配置了
二、普通查看(不使用k8s)
查看镜像
sudo docker images | grep 镜像名字
查看镜像的详细信息
docker image inspect 7517753b91ca
找到RootDir,通过cd命令进入目录,需要root权限
sudo cd /var/lib/docker/overlay/8a1defde1405c4ad9ee22830f3dac0bab42a492cbb55109364f3e968db3eab30/root
可以看到有个jar包了
文本末
参考文档:https://blog.csdn.net/qq_20042935/article/details/126852644
参考文档:https://blog.csdn.net/zh452647457/article/details/120215300文章来源:https://www.toymoban.com/news/detail-654624.html
参考文档:https://blog.csdn.net/coolcoffee168/article/details/90602964文章来源地址https://www.toymoban.com/news/detail-654624.html
到了这里,关于docker查看镜像中的jar的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!