Docker compose keeps network up after containers stop












2















My CI/CD runs tests using docker compose. I use --abort-on-container-exit option so compose stops all the containers once the test container has finished.



However it seems that networks created by compose are still up. This is an issue, as we quickly reach the networks definitions limits in Docker.



I looked at the documentation for a way to remove the networks once the containers exit, but I couldn't find anything. I think I could just do a docker-compose stop, but that doesn't fit well with my Jenkins pipeline.



Is there a way to achieve this either through docker-compose up options or in the compose manifest ?










share|improve this question

























  • you can create an system cronjob and run docker network prune -f

    – Truong Dang
    Nov 27 '18 at 8:05











  • You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

    – benjamin.d
    Nov 27 '18 at 8:09











  • Do you also remove the containers? Would docker-compose down be an option here?

    – tgogos
    Nov 27 '18 at 13:55











  • Yes I guess that could be an option

    – benjamin.d
    Nov 27 '18 at 17:09
















2















My CI/CD runs tests using docker compose. I use --abort-on-container-exit option so compose stops all the containers once the test container has finished.



However it seems that networks created by compose are still up. This is an issue, as we quickly reach the networks definitions limits in Docker.



I looked at the documentation for a way to remove the networks once the containers exit, but I couldn't find anything. I think I could just do a docker-compose stop, but that doesn't fit well with my Jenkins pipeline.



Is there a way to achieve this either through docker-compose up options or in the compose manifest ?










share|improve this question

























  • you can create an system cronjob and run docker network prune -f

    – Truong Dang
    Nov 27 '18 at 8:05











  • You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

    – benjamin.d
    Nov 27 '18 at 8:09











  • Do you also remove the containers? Would docker-compose down be an option here?

    – tgogos
    Nov 27 '18 at 13:55











  • Yes I guess that could be an option

    – benjamin.d
    Nov 27 '18 at 17:09














2












2








2








My CI/CD runs tests using docker compose. I use --abort-on-container-exit option so compose stops all the containers once the test container has finished.



However it seems that networks created by compose are still up. This is an issue, as we quickly reach the networks definitions limits in Docker.



I looked at the documentation for a way to remove the networks once the containers exit, but I couldn't find anything. I think I could just do a docker-compose stop, but that doesn't fit well with my Jenkins pipeline.



Is there a way to achieve this either through docker-compose up options or in the compose manifest ?










share|improve this question
















My CI/CD runs tests using docker compose. I use --abort-on-container-exit option so compose stops all the containers once the test container has finished.



However it seems that networks created by compose are still up. This is an issue, as we quickly reach the networks definitions limits in Docker.



I looked at the documentation for a way to remove the networks once the containers exit, but I couldn't find anything. I think I could just do a docker-compose stop, but that doesn't fit well with my Jenkins pipeline.



Is there a way to achieve this either through docker-compose up options or in the compose manifest ?







docker jenkins docker-compose continuous-integration docker-networking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 22:10









kofemann

2,5982127




2,5982127










asked Nov 26 '18 at 22:08









benjamin.dbenjamin.d

2,07231227




2,07231227













  • you can create an system cronjob and run docker network prune -f

    – Truong Dang
    Nov 27 '18 at 8:05











  • You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

    – benjamin.d
    Nov 27 '18 at 8:09











  • Do you also remove the containers? Would docker-compose down be an option here?

    – tgogos
    Nov 27 '18 at 13:55











  • Yes I guess that could be an option

    – benjamin.d
    Nov 27 '18 at 17:09



















  • you can create an system cronjob and run docker network prune -f

    – Truong Dang
    Nov 27 '18 at 8:05











  • You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

    – benjamin.d
    Nov 27 '18 at 8:09











  • Do you also remove the containers? Would docker-compose down be an option here?

    – tgogos
    Nov 27 '18 at 13:55











  • Yes I guess that could be an option

    – benjamin.d
    Nov 27 '18 at 17:09

















you can create an system cronjob and run docker network prune -f

– Truong Dang
Nov 27 '18 at 8:05





you can create an system cronjob and run docker network prune -f

– Truong Dang
Nov 27 '18 at 8:05













You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

– benjamin.d
Nov 27 '18 at 8:09





You’re right and that’s what I am doing right now but I was looking at a solution where I was pruning only the networks created running the last docker compose run. If there is no such option in docker compose run I’ll stick to this solution

– benjamin.d
Nov 27 '18 at 8:09













Do you also remove the containers? Would docker-compose down be an option here?

– tgogos
Nov 27 '18 at 13:55





Do you also remove the containers? Would docker-compose down be an option here?

– tgogos
Nov 27 '18 at 13:55













Yes I guess that could be an option

– benjamin.d
Nov 27 '18 at 17:09





Yes I guess that could be an option

– benjamin.d
Nov 27 '18 at 17:09












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489867%2fdocker-compose-keeps-network-up-after-containers-stop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489867%2fdocker-compose-keeps-network-up-after-containers-stop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Lallio

Unable to find Lightning Node

Futebolista