testcontainers-python icon indicating copy to clipboard operation
testcontainers-python copied to clipboard

no -v option in docker-compose down

Open NikZak opened this issue 3 years ago • 4 comments

Currently DockerCompose object is stopped like this.

    def stop(self):
        down_cmd = self.docker_compose_command() + ['down', '-v']
        subprocess.call(down_cmd, cwd=self.filepath)

The '-v' option is firmly coded - I would like to be able to choose the options for stop command. Sometimes I don't want the volumes to be removed

NikZak avatar Feb 03 '22 15:02 NikZak

Actually in

class DockerContainer(object):

you have a parameter for deleting containers after use

    def stop(self, force=True, delete_volume=True):
        self.get_wrapped_container().remove(force=force, v=delete_volume)

So just to need to make this consistent across the repo. Maybe something along these lines in DockerCompose:

    def stop(self, delete_volume=True):
        down_cmd = self.docker_compose_command() + ['down'] + (['-v'] if delete_volume else [])
        subprocess.call(down_cmd, cwd=self.filepath)

NikZak avatar Feb 04 '22 02:02 NikZak

Thanks for reporting, @NikZak. Are you up for putting together a PR?

tillahoffmann avatar Apr 01 '22 13:04 tillahoffmann

I can make a PR but will you be able to quickly merge it? Just asking because I made prs in repos and now have a confirmation coming every three months and after a year they're still not merged. It's discouraging

NikZak avatar Apr 01 '22 16:04 NikZak

We will review it as soon as possible

yakimka avatar Apr 02 '22 12:04 yakimka