nerdctl
nerdctl copied to clipboard
nerdctl compose removes containers on termination (stop vs down)
I use nerdctl in a lima vm on mac as a replacement for docker-compose.
docker compose (or docker-compose) supports a stop command. It retains the created containers by just stopping them. In oppose to that, the down command removes the containers after stopping. nerdctl only has the down command.
When I run nerdctl up and ctrl-c the process, this is effectively a down and the containers are removed.
One can reproduce this with a simple docker-compose.yml file:
version: '3'
services:
test:
image: nginx
ports:
- 1234:80
$ lima nerdctl compose up
INFO[0000] Ensuring image nginx
INFO[0000] Creating container docker-compose_test_1
…
# ctrl+c
INFO[0295] Stopping containers (forcibly)
INFO[0295] Stopping container docker-compose_test_1
$ lima nerdctl ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# [no containers]
With the original docker-compose the stopped containers are still present:
$ docker-compose up
Creating network "docker-compose_default" with the default driver
Creating docker-compose_test_1 ... done
…
# ctrl+c
Gracefully stopping... (press Ctrl+C again to force)
Stopping docker-compose_test_1 ... done
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
013c0570007f nginx "/docker-entrypoint.…" 29 seconds ago Exited (0) 12 seconds ago docker-compose_test_1
Proposal:
- add
nerdctl compose stopcommand (and probablystart?) - let the
ctrl-csignal listener innerdctl compose uptrigger the stop command instead of down.
$ nerdctl version
Client:
Version: v0.15.0
Git commit: b72b5ca14550b2e23a42787664b6182524c5053f
Server:
containerd:
Version: v1.5.8
GitCommit: 1e5ef943eb76627a6d3b6de8cd1ef6537f393a71
I definitely second that. Fair to mention though that nerdctl stop can be used for now as a workaround until nerdctl compose stop has been implemented. Just if that was not already clear.
I think this proposal is making sense.
I will make a try to impl it.
cc @AkihiroSuda would you mind assigning this issue to me?
Any news about this 'stop' command implementation ? :) Best will be also to just start the stop containers defined in the compose file to not loose volumes associated. Thank you !
Any news about this 'stop' command implementation ? :)
Best will be also to just start the stop containers defined in the compose file to not loose volumes associated.
Thank you !
Working on it now,maybe this feature can be released in v0.23.0
+1
Maintaining volumes is a really important feature; thank you for the great work!
@Zheaoli are you still working on this? Otherwise I'd like to give it a try.
@djdongjin Sure you can make a try