由于键名中包含字符“.”,我在从映射列表中获取值时遇到了问题。
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
<no value>
)字符以正确转义。\\
"com.docker.compose.project\`" - devlifeloki-external-labels: container_name={{.Name}},cluster=${COMPOSE_PROJECT_NAME},service={{ index .Config.Labels 'com.docker.compose.service' }}
。如果出现“loki: could not expand label value”错误,我哪里做错了? - wapmorgan