参见英文答案 > How can I get a Docker image’s label if the label name has a “.” in it? 1个
由于密钥具有“.”,因此我无法从地图列表中获取值.内.
docker inspect jenkins ... Config: { .. "Labels": { "com.docker.compose.config-hash": "85bcf1e0bcd708120185a303e2a8d8e65543c1ec77ec0c6762fc057dc10320aa","com.docker.compose.container-number": "1","com.docker.compose.oneoff": "False","com.docker.compose.project": "new","com.docker.compose.service": "sc2","com.docker.compose.version": "1.5.2" } } }
我可以获得地图列表
docker inspect -f {{.Config.Labels}} new_sc2_1 map[com.docker.compose.config-hash:85bcf1e0bcd708120185a303e2a8d8e65543c1ec77ec0c6762fc057dc10320aa com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:new com.docker.compose.service:sc2 com.docker.compose.version:1.5.2]
但是如何从密钥com.docker.compose.project获取项目名称new
docker inspect -f {{.Config.Labels.com.docker.compose.project}} new_sc2_1
最佳答案
原文链接:https://www.f2er.com/docker/436827.html