You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: not to be deleted a container created with --rm when detaching
In the current implementation, detaching from a container started with
`nerdctl run --rm ...` unexpectedly removes it.
The behaviour before this modification is as follows.
```
> nerdctl run --rm -it --detach-keys=ctrl-a,ctrl-b --name test alpine
/ # INFO[0002] read detach keys
> nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
```
When the same operation is performed in the Docker CLI, the container will
not be deleted.
This issue is reported in the following:
- #3568
Therefore, this commit resolves this behaviour of a container not being
deleted on detachment.
Note that the behaviour after this modification is as follows.
```
> nerdctl run --rm -it --detach-keys=ctrl-a,ctrl-b --name test alpine
/ # INFO[0010] read detach keys
> nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
46f4c829e5cc docker.io/library/alpine:latest "/bin/sh" 15 seconds ago Up test
```
This PR has also been modified to remove a container when detaching and
attaching a container started with the --rm option.
The detailed behaviour is as follows.
```
> nerdctl attach test
/ # exit
> nerdctl ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
```
Signed-off-by: Hayato Kiwata <haytok@amazon.co.jp>
Description: "Issue #3568 - Detaching from a container started by using --rm option causes the container to be deleted.",
532
+
// When detaching from a container, for a session started with 'docker attach', it prints 'read escape sequence', but for one started with 'docker (run|start)', it prints nothing.
533
+
// However, the flag is called '--detach-keys' in all cases, so nerdctl prints 'read detach keys' for all cases, and that's why this test is skipped for Docker.
0 commit comments