nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

FATA[0000] flag -d and --rm cannot be specified together

Open james-work-account opened this issue 3 years ago • 9 comments

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

james-work-account avatar Jul 04 '22 11:07 james-work-account

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

liubin avatar Jul 05 '22 07:07 liubin

@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?

manugupt1 avatar Sep 29 '22 00:09 manugupt1

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

AkihiroSuda avatar Sep 29 '22 02:09 AkihiroSuda

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

yuchanns avatar Oct 06 '22 09:10 yuchanns

Can we rather just extend the restart monitor to support removal? https://github.com/containerd/containerd/tree/main/runtime/restart

Not "restart" though

AkihiroSuda avatar Oct 06 '22 09:10 AkihiroSuda

↑ @junnplus WDYT?

AkihiroSuda avatar Oct 19 '22 03:10 AkihiroSuda

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.

junnplus avatar Oct 20 '22 09:10 junnplus

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.

yuchanns avatar Oct 22 '22 18:10 yuchanns

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.

Yes

AkihiroSuda avatar Dec 17 '22 04:12 AkihiroSuda