From 3f7c129b6dd7461fe39b423f6bb179159b99f822 Mon Sep 17 00:00:00 2001 From: Alec Reynolds Date: Tue, 22 Oct 2024 10:35:04 -0700 Subject: [PATCH 1/2] #244: Variable for setting the network limit. --- docs/networking.md | 6 ++++++ plugins/networking/index.js | 2 +- utils/get-config-defaults.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/networking.md b/docs/networking.md index af3943ef7..65274ebfd 100644 --- a/docs/networking.md +++ b/docs/networking.md @@ -58,3 +58,9 @@ You can also use the environment variable `LANDO_HOST_IP`. ```sh lando exec my-service -- ping "\$LANDO_HOST_IP" -c 3 ``` + +## Network Limits + +By default Docker has a limit of 32 networks. If you're running a large number of sites, you'll see a message `Lando has detected you are at Docker's network limit`, after which Lando will attempt to clean up unused networks to put you below the network limit. + +If you've [modified your Docker daemon](https://discussion.fedoraproject.org/t/increase-limit-of-30-docker-networks-in-a-clean-way/96622/4) to allow more networks, you can set Lando's network limit to a higher number by setting the `networkLimit` variable in [Lando's global config](./global.html). diff --git a/plugins/networking/index.js b/plugins/networking/index.js index 8368ab7f8..c0b7a473e 100644 --- a/plugins/networking/index.js +++ b/plugins/networking/index.js @@ -8,7 +8,7 @@ const _ = require('lodash'); */ const cleanNetworks = lando => lando.engine.getNetworks() .then(networks => { - if (_.size(networks) >= 32) { + if (_.size(networks) >= lando.config.networkLimit) { // Warn user about this action lando.log.warn('Lando has detected you are at Docker\'s network limit!'); lando.log.warn('Give us a moment as we try to make space by cleaning up old networks...'); diff --git a/utils/get-config-defaults.js b/utils/get-config-defaults.js index 45e446db9..5441dccdc 100644 --- a/utils/get-config-defaults.js +++ b/utils/get-config-defaults.js @@ -28,6 +28,7 @@ const defaultConfig = options => ({ home: os.homedir(), isArmed: _.includes(['arm64', 'aarch64'], process.arch), logLevel: 'debug', + networkLimit: 32, node: process.version, os: { type: os.type(), From 09fe395de4d9a102fd15a82c79655fe7718b9410 Mon Sep 17 00:00:00 2001 From: Alec Reynolds <1153738+reynoldsalec@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:38:33 -0800 Subject: [PATCH 2/2] #244: Add test for the networkLimit config var. --- examples/networking/README.md | 7 +++++++ examples/networking/config.yml | 1 + 2 files changed, 8 insertions(+) create mode 100644 examples/networking/config.yml diff --git a/examples/networking/README.md b/examples/networking/README.md index 5b4e507e9..5b639135f 100644 --- a/examples/networking/README.md +++ b/examples/networking/README.md @@ -22,6 +22,10 @@ cp -rf index.php lemp/index.php cp -rf nginx.conf lemp/nginx.conf cp -rf .lando.lemp.yml lemp/.lando.yml cd lemp && lando start + +# Should copy .config.yml to ~/.lando/config.yml +cp config.yml ~/.lando/config.yml +lando --clear ``` ## Verification commands @@ -63,6 +67,9 @@ lando exec appserver_nginx -- curl https://appserver.landolamp.internal # Should even be able to connect to a database in a different app cd lamp lando exec database -- mysql -uroot -h database.landolemp.internal -e "quit" + +# Should see the correct network limit +lando config | grep "networkLimit: 64" ``` ## Destroy tests diff --git a/examples/networking/config.yml b/examples/networking/config.yml new file mode 100644 index 000000000..558339625 --- /dev/null +++ b/examples/networking/config.yml @@ -0,0 +1 @@ +networkLimit: 64