过去,使用 podman 删除 pod 失败了,现在我处于不一致的状态,我不知道如何修复。显然,磁盘上删除了 infra 容器的存储,但 podman 仍然认为该容器存在。我的 root 实例和 rootless 实例都有一个这样的容器。请帮我弄清楚如何清理它(删除对不再存在的这个 pod 的引用,并删除 infra 容器……)
主机系统是Fedora 29 Silverblue。
podman 输出...
[bnordgren@brycelap ~]$ podman pod ls
POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID
e61ac0328400 test Created 4 weeks ago 1 31770c3e3fda
[bnordgren@brycelap ~]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31770c3e3fda k8s.gcr.io/pause:3.1 4 weeks ago Created e61ac0328400-infra
[bnordgren@brycelap ~]$ podman --log-level debug pod rm -f e61
INFO[0000] running as rootless
DEBU[0000] Initializing boltdb state at /var/home/bnordgren/.local/share/containers/storage/libpod/bolt_state.db
DEBU[0000] Using graph driver overlay
DEBU[0000] Using graph root /var/home/bnordgren/.local/share/containers/storage
DEBU[0000] Using run root /run/user/1000
DEBU[0000] Using static dir /var/home/bnordgren/.local/share/containers/storage/libpod
DEBU[0000] Using tmp dir /run/user/1000/libpod/tmp
DEBU[0000] Using volume path /var/home/bnordgren/.local/share/containers/storage/volumes
DEBU[0000] Set libpod namespace to ""
DEBU[0000] Not configuring container store
INFO[0000] running as rootless
WARN[0000] The configuration is using `runtime_path`, which is deprecated and will be removed in future. Please use `runtimes` and `runtime`
WARN[0000] If you are using both `runtime_path` and `runtime`, the configuration from `runtime_path` is used
DEBU[0000] Initializing boltdb state at /var/home/bnordgren/.local/share/containers/storage/libpod/bolt_state.db
DEBU[0000] Using graph driver overlay
DEBU[0000] Using graph root /var/home/bnordgren/.local/share/containers/storage
DEBU[0000] Using run root /run/user/1000
DEBU[0000] Using static dir /var/home/bnordgren/.local/share/containers/storage/libpod
DEBU[0000] Using tmp dir /run/user/1000/libpod/tmp
DEBU[0000] Using volume path /var/home/bnordgren/.local/share/containers/storage/volumes
DEBU[0000] Set libpod namespace to ""
DEBU[0000] [graphdriver] trying provided driver "overlay"
DEBU[0000] overlay: mount_program=/usr/bin/fuse-overlayfs
DEBU[0000] backingFs=extfs, projectQuotaSupported=false, useNativeDiff=false, usingMetacopy=false
DEBU[0000] Cleaning up container 31770c3e3fdabb91b2a8ccd2856a947782b5a6dcb02670efb4a39bb2a9773c74
DEBU[0000] Network is already cleaned up, skipping...
DEBU[0000] Storage is already unmounted, skipping...
DEBU[0000] Storage is already unmounted, skipping...
WARN[0000] Storage for container 31770c3e3fdabb91b2a8ccd2856a947782b5a6dcb02670efb4a39bb2a9773c74 already removed
ERRO[0000] no such file or directory
答案1
假设您不想$HOME/.local/share/containers
直接删除,则需要编辑一些 JSON 文件。
podman
如果可能的话,关闭所有容器。- 查找 SHA256 条目,
$HOME/.local/share/containers/storage/overlay-containers/containers.json
除了您尝试修复的容器的条目之外,您还应该看到每个有效容器的条目。 - 删除您希望 podman 忘记的与 SHA256 容器相对应的完整条目。
以下是我系统中的一个例子,用来jq
让事情变得漂亮。我目前有两个 podman 容器:fcb8454b75ad / freedv 和 8456a27c0f4c / tang。如果 freedv 容器像你的一样“消失”,我会删除第二部分,包括第一部分右括号后面的逗号,保留最后的右方括号:
}, <-- Remove the comma but not the closing brace.
{
"id": "fcb8454b75ad8
...
"ProcessLabel": ""
}
} <-- Remove this.
] <-- Leave this
这是修改之前的完整文件:
[
{
"id": "8456a27c0f4c2d1492f45263b97b0e5e4f9a688e6aed26a2270f490b2be04155",
"names": [
"tang"
],
"image": "9b21690ebd2027c33705ab485c699fb8f4c4d618b2e80294ee2041e8e7f3f840",
"layer": "a8262df0b380a570868d5d6b619c62bec3b053ae7732810324dc594af3023a9e",
"metadata": "{\"image-name\":\"docker.io/malaiwah/tang:latest\",\"image-id\":\"9b21690ebd2027c33705ab485c699fb8f4c4d618b2e80294ee2041e8e7f3f840\",\"name\":\"tang\",\"created-at\":1573364175}",
"created": "2019-11-10T05:36:15.150718037Z",
"flags": {
"MountLabel": "system_u:object_r:container_file_t:s0:c158,c440",
"ProcessLabel": "system_u:system_r:container_t:s0:c158,c440"
}
},
{
"id": "fcb8454b75ad8f2ff2b610e10b16067fdd94015e5166c78b771cc4732b706b98",
"names": [
"freedv"
],
"image": "a198bc8c3cda783856295d4d4859668217afc4ffc6f79a171c896f1b13e5ed21",
"layer": "9107cb88795602ce1507b39bc56e46f212e6d0a268fa467809d9d7b7d777ce75",
"metadata": "{\"image-name\":\"registry.fedoraproject.org/f31/fedora-toolbox:31\",\"image-id\":\"a198bc8c3cda783856295d4d4859668217afc4ffc6f79a171c896f1b13e5ed21\",\"name\":\"freedv\",\"created-at\":1575051814}",
"created": "2019-11-29T18:23:34.237852598Z",
"flags": {
"MountLabel": "system_u:object_r:container_file_t:s0:c662,c960",
"ProcessLabel": ""
}
}
]
修改后:
[
{
"id": "8456a27c0f4c2d1492f45263b97b0e5e4f9a688e6aed26a2270f490b2be04155",
"names": [
"tang"
],
"image": "9b21690ebd2027c33705ab485c699fb8f4c4d618b2e80294ee2041e8e7f3f840",
"layer": "a8262df0b380a570868d5d6b619c62bec3b053ae7732810324dc594af3023a9e",
"metadata": "{\"image-name\":\"docker.io/malaiwah/tang:latest\",\"image-id\":\"9b21690ebd2027c33705ab485c699fb8f4c4d618b2e80294ee2041e8e7f3f840\",\"name\":\"tang\",\"created-at\":1573364175}",
"created": "2019-11-10T05:36:15.150718037Z",
"flags": {
"MountLabel": "system_u:object_r:container_file_t:s0:c158,c440",
"ProcessLabel": "system_u:system_r:container_t:s0:c158,c440"
}
}
]