上周我不得不从我的 Docker Swarm 集群中删除一个失败的节点,让在该节点上运行的一些任务处于所需的状态“删除”。
即使在删除堆栈并使用相同名称重新创建它之后,docker stack ps stackname
仍然显示它们。
有趣的是,在重新创建堆栈后,任务仍然存在,但没有分配节点。
到目前为止,这是我尝试“清理”堆栈的方法:
docker container prune
docker volume prune
docker system prune
有没有办法删除特定任务?
这是
docker inspect fkgz0oihexzs
的输出,列表中的第一个任务:[
{
"ID": "fkgz0oihexzsjqwv4ju0szorh",
"Version": {
"Index": 14422171
},
"CreatedAt": "2018-11-05T16:15:31.528933998Z",
"UpdatedAt": "2018-11-05T16:27:07.422368364Z",
"Labels": {},
"Spec": {
"ContainerSpec": {
"Image": "redacted",
"Labels": {
"com.docker.stack.namespace": "redacted"
},
"Env": [
"redacted"
],
"Privileges": {
"CredentialSpec": null,
"SELinuxContext": null
},
"Isolation": "default"
},
"Resources": {},
"Placement": {
"Platforms": [
{
"Architecture": "amd64",
"OS": "linux"
}
]
},
"Networks": [
{
"Target": "3i998stqemnevzgiqw3ndik4f",
"Aliases": [
"redacted"
]
}
],
"ForceUpdate": 0
},
"ServiceID": "g3vk9tgfibmcigmf67ik7uhj6",
"Slot": 1,
"Status": {
"Timestamp": "2018-11-05T16:15:31.528892467Z",
"State": "new",
"Message": "created",
"PortStatus": {}
},
"DesiredState": "remove"
}
]
最佳答案
我有同样的问题。我通过以下方式解决了 this instructions :
docker run --rm -v /var/run/docker/swarm/control.sock:/var/run/swarmd.sock dperny/tasknuke <taskid>
请务必使用完整的长任务 ID,否则它将无法工作(在您的情况下为
fkgz0oihexzsjqwv4ju0szorh
)。
关于docker - 移除故障节点后 Docker Swarm 中的孤立任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53170286/