nerdctl
nerdctl copied to clipboard
FATA[0000] flag -d and --rm cannot be specified together
What is the problem you're trying to solve
When using colima, the command docker run --rm -d --name mongo -p 27017:27017 mongo:latest works fine. However I've been required to switch to nerdctl, and the command lima nerdctl run --rm -d --name mongo -p 27017:27017 mongo:latest outputs the error:
FATA[0000] flag -d and --rm cannot be specified together
Describe the solution you'd like
Ultimately, I would like to repeatedly be able to start mongo through Docker without getting name "mongo" is already used by ID "XYZ" errors. Using the same method with Colima and nerdctl give me different results - I am not particularly fluent with Docker stuff so if this isn't the correct way of doing this then I'm open to suggestions!
Additional context
No response
If you are using a shell script, as a workaround, you can delete it first without waiting for nerdtcl to support these two options being specified together :
nerdctl rm mongo -f || true
nerdctl run -d --name mongo
@AkihiroSuda @Zheaoli I tried this issue a few weeks back, where I got stuck was on how to clean up the resources. The approach that I tried was invoking the nerdctl postStop oci hook but the postStop hook executes before deleting the container which is not what we want today.
Do you have suggestions?
Maybe too strange, but I guess we can execute sh -euc "sleep 3 && nerdctl rm -f <CONTAINER>" & in the postStop hook.
Or set a systemd timer when systemd is available
we can execute sh -euc "sleep 3 && nerdctl rm -f <CONTAINER>" & in the postStop hook
That's weird.
How about hanging discontinuous responses until periodically checking has ensured containers are deleted?
$ nerdctl run --rm -d alpine echo hello world
# 047e8df4994637a8b069e1155df6e55d09326e88f13858ea9571d30ac36d92e8
## hanging periodically check until the container is deleted
## or just fork a daemon to do that
Can we rather just extend the restart monitor to support removal? https://github.com/containerd/containerd/tree/main/runtime/restart
Not "restart" though
↑ @junnplus WDYT?
Can we rather just extend the restart monitor to support removal? https://github.com/containerd/containerd/tree/main/runtime/restart
Not "restart" though
SGTM, I had the same idea before, but didn't study it carefully.
Can we rather just extend the restart monitor to support removal?
Not "restart" though
From my understanding, do you mean to manage the delete after stop by upstream containerd?
So there should be a delete policy plugin or something like that, periodically monitoring if containers with a delete policy are stopped and then delete them.
Can we rather just extend the restart monitor to support removal? Not "restart" though
From my understanding, do you mean to manage the
delete after stopby upstream containerd?So there should be a delete policy plugin or something like that, periodically monitoring if containers with a delete policy are stopped and then delete them.
Yes