Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

dockerComposeRestart and the network limit #39

Closed
mb720 opened this issue Jan 12, 2017 · 3 comments
Closed

dockerComposeRestart and the network limit #39

mb720 opened this issue Jan 12, 2017 · 3 comments

Comments

@mb720
Copy link

mb720 commented Jan 12, 2017

Hi!

Having a great time with your plugin!

When developing, I use dockerComposeRestart to restart my application with the changes I made to it.
This works great for a while, but since there's a limitation to the number of Docker networks you can have, I get this message when trying to create the 32nd network :

failed to parse pool request for address space "LocalDefault" pool "" subpool "": could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

After removing a network, I can start the application again.

I guess this could be fixed if dockerComposeRestart were an alias for docker-compose down && docker-compose up since docker-compose down removes the network.

Thanks!

@kurtkopchik
Copy link
Contributor

kurtkopchik commented Jan 12, 2017

Hi @mb720, I'm glad that you are enjoying the Plugin!

There is code in the plugin to remove any networks that are created. However, it needs to know the name of the docker machine being used if it's something other than default.

There is a settingKey you can override in your build.sbt file with an alternate name for the docker machine if it's something other than default

dockerMachineName:="customDockerMachineName"

Here is the plugin code for network removal that should run when the containers are stopped during the restart process:

    if (getSetting(composeRemoveNetworkOnShutdown)) {
      // If the compose file being used is a version that creates a new network on startup then remove that network on
      // shutdown
      if (new File(composePath).exists()) {
        val composeYaml = readComposeFile(composePath)
        if (getComposeVersion(composeYaml) >= 2) {
          val dockerMachine = getSetting(dockerMachineName)
          dockerRemoveNetwork(instanceName, dockerMachine)
        }
      }
    }
 def dockerRemoveNetwork(networkName: String, dockerMachineName: String): Unit = {
    s"docker network rm ${networkName}_$dockerMachineName".!
  }

Hopefully that is the issue. Otherwise, we will have to investigate further.

@mb720
Copy link
Author

mb720 commented Jan 12, 2017

Thanks for your quick reply, Kurt!

Ah, I see. I was wondering why I was getting those errors every time I called dockerComposeStop:

Error response from daemon: network 899837_default not found

After adding the following to build.sbt, the network is removed properly:
dockerMachineName := s"${appName}-network"

Is that the settingKey you meant?

I should mention that I'm currently on Windows 10 x64.

@kurtkopchik
Copy link
Contributor

Hi @mb720,

Happy to hear that it's working for you now! And it's really great to hear you are on Windows 10 as the code was written to not have anything that was OS dependent but we never tested it before on Windows 10.

Yes, dockerMachineName was the key I meant to specify. (I've updated it in the previous comment.)

Thanks again for using the plugin and providing feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants