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
fix: ensure no duplicates for docker networks, fixes #5193 #5508
fix: ensure no duplicates for docker networks, fixes #5193 #5508
Conversation
Download the artifacts for this pull request:
See Testing a PR |
I never had the duplicate networks on Linux (docker v24.0.5), but with your "broken" build I can reproduce.
On
With this PR (v1.22.5-alpha1-4-g8ccbe6ba1) they get removed on But I am not sure if network removal should be in EDIT: We also have the network labels that we added in 1.22.4. I am not sure if we are using them in |
@jonaseberle Thank you!
I agree, I thought just one "for" loop for networks would be good, but now it's not clear what's going on with the function name. I will create a new function to remove duplicates (or move it somewhere, don't know yet). I need to think more about
We use them to remove all leftovers from Docker, so if something goes wrong it'll still be cleaned up here. It's true that currently duplicates cannot be removed in v1.22.4 (because of the check for network name, not ID), but with my change in this PR it will finally be handled properly. |
8ccbe6b
to
c6b9e44
Compare
I made a new function The first post of this PR now has a summary where I've gathered all the information about this issue in one place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is looking great, but when I ddev restart
I get errors like this:
$ ddev restart d10
Restarting project d10...
Container ddev-d10-db Stopped
Container ddev-d10-web Stopped
Container ddev-d10-db Stopped
Container ddev-d10-web Stopped
Container ddev-d10-db Removed
Container ddev-d10-web Removed
Unable to remove network ddev-d10_default: API error (403): error while removing network: network ddev-d10_default id 169ec45f14920cef6a487cc8be020647f9d81e69187a53d7d37464b61aa103fd has active endpoints
This is using orbstack, I doubt that matters.
That problem was due to an abandoned container left by a removed add-on (xhgui). I don't think it has anything to do with this. Fix is in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually tested with the broken ddev that creates extra networks, and it works perfectly with the manual testing technique.
I looked at the code and it's elegant and nice. Thanks! 💯
The Issue
Summary:
Sometimes when you start a project, multiple project networks are created (e.g.
ddev-your-project_default
) which prevents the project from starting.The project network is internal (created from
docker-compose.yaml
) in v1.22.4, and we cannot manipulate its state.But we can make it external (created programmatically from DDEV, see #5305) in v1.22.5 and control it however we want.But we can create it programmatically from DDEV (see #5533) in v1.22.5 and control it however we want.We can only check for network duplicates, as this is fixed in Docker v25+.
This set of PRs are intended to fix the need for user to do manually
docker network rm
, because the project cannot be started when there are duplicate networks.An attempt has been made to fix this on the Docker side (but it will only be available with Docker 25):
To make things easier for DDEV users, we can manually create networks for DDEV projects and automatically remove duplicates.
Code changes for this issue are made in:
ddev start
, fixes #5810 #5848How This PR Solves The Issue
DDEV should remove Docker networks by ID, not by name. This way users won't need to worry about duplicate networks, because they will be removed automatically on
ddev start
andddev poweroff
- regardless of what users run.Manual Testing Instructions
Download the binary below, this is a special broken binary that creates duplicate networks:
Automated Testing Overview
Related Issue Link(s)
Release/Deployment Notes