Repository navigation
fix: resolve compose project name from compose config - #844
Open
bunnysayzz wants to merge 1 commit into
Open
bunnysayzz wants to merge 1 commit into
bunnysayzz wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #842.
When two compose projects on the same daemon run a service with the same name, lazydocker bound the wrong project's container to the local service: shift-E shelled into the other project's container and the services tab showed the wrong name.
Root cause: LocalProjectName was inferred by scanning the daemon-wide container list and taking the project of the first container whose service name matched a local service name. With a same-named service in another project, list order picked the project and poisoned every local service binding.
The fix asks compose itself. GetServices now runs
docker compose config --format jsonand takes the top-levelname, which compose resolves the same way it does at runtime (-p, COMPOSE_PROJECT_NAME, thename:directive, then the directory name). The container-list scan is gone; the only fallback left is the directory name, which is compose's own last resort. Old docker-compose binaries without --format json fall back toconfig --servicesas before.Tests: TestParseComposeConfigJSON (+ invalid and empty cases) and TestAssignContainersToServicesPicksOwnProject, which replays the issue's two-projects-one-service-name setup with the foreign container first in list order.
go test ./pkg/commands/passes, vet clean. No docker daemon here so the GUI path itself is untested, the parsing and binding logic is covered.