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

[Enhancement]: DockerComposeContainer: Add option for down -v in stop() #7008

Closed
gabrielsson opened this issue May 3, 2023 · 2 comments · Fixed by #7009
Closed

[Enhancement]: DockerComposeContainer: Add option for down -v in stop() #7008

gabrielsson opened this issue May 3, 2023 · 2 comments · Fixed by #7009

Comments

@gabrielsson
Copy link

Module

Core

Proposal

As the testcontainers-python issue testcontainers/testcontainers-python#178

We have the same thing with

    @Override
    public void stop() {
        ...
                // Kill the services using docker-compose
                String cmd = "down -v";
                if (removeImages != null) {
                    cmd += " --rmi " + removeImages.dockerRemoveImagesType();
                }
                runWithCompose(cmd);

        ...
    }

It would be be a good thing to introduce a parameter much like the removeImages

to something like

    @Override
    public void stop() {
        ...
                // Kill the services using docker-compose
                String cmd = "down";
                if (removeVolumes == true) { //defaults to true
                    cmd += " -v";
                }
                if (removeImages != null) {
                    cmd += " --rmi " + removeImages.dockerRemoveImagesType();
                }
                runWithCompose(cmd);

        ...
    }
@DanWiseProgramming
Copy link
Contributor

Hi, just to let you know that I am working on this issue.

DanWiseProgramming added a commit to DanWiseProgramming/testcontainers-java that referenced this issue May 3, 2023
DanWiseProgramming added a commit to DanWiseProgramming/testcontainers-java that referenced this issue May 3, 2023
@gabrielsson
Copy link
Author

I've tested this code and works like a charm for my usecase.
I have a container with pre-populated base data as part of my development flow and it takes some time to build this and is not feasible to do during test.

eddumelendez added a commit that referenced this issue May 12, 2023
Closes #7008 


Co-authored-by: Eddú Meléndez <eddu.melendez@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants