Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nerdctl compose removes containers on termination (stop vs down) #666

Closed
filex opened this issue Jan 5, 2022 · 8 comments · Fixed by #1494
Closed

nerdctl compose removes containers on termination (stop vs down) #666

filex opened this issue Jan 5, 2022 · 8 comments · Fixed by #1494
Assignees
Labels
area/compose enhancement New feature or request

Comments

@filex
Copy link

filex commented Jan 5, 2022

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 stop command (and probably start?)
  • let the ctrl-c signal listener in nerdctl compose up trigger the stop command instead of down.
@filex
Copy link
Author

filex commented Jan 5, 2022

$ nerdctl version
Client:
 Version:	v0.15.0
 Git commit:	b72b5ca14550b2e23a42787664b6182524c5053f

Server:
 containerd:
  Version:	v1.5.8
  GitCommit:	1e5ef943eb76627a6d3b6de8cd1ef6537f393a71

@AkihiroSuda AkihiroSuda added area/compose enhancement New feature or request labels Jan 5, 2022
@kgalli
Copy link

kgalli commented Jan 12, 2022

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.

@Zheaoli
Copy link
Member

Zheaoli commented Mar 25, 2022

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?

@Hellboy94520
Copy link

Hellboy94520 commented Jul 16, 2022

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 !

@Zheaoli
Copy link
Member

Zheaoli commented Jul 16, 2022

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

@egelja
Copy link

egelja commented Aug 8, 2022

+1

Maintaining volumes is a really important feature; thank you for the great work!

@djdongjin
Copy link
Member

@Zheaoli are you still working on this? Otherwise I'd like to give it a try.

@Zheaoli
Copy link
Member

Zheaoli commented Nov 9, 2022

@djdongjin Sure you can make a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/compose enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants