Skip to content
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

restore setEnvWithDotEnv #11974

Merged
merged 1 commit into from
Jul 11, 2024
Merged

restore setEnvWithDotEnv #11974

merged 1 commit into from
Jul 11, 2024

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Jul 8, 2024

What I did
restore setEnvWithDotEnv to load .env into os.Env so the many places we rely on os.LookupEnv aren't borken
this also restore support for configuring buildx using env var set in .env

includes e2e test + a tiny fix to include (stopped) one-off containers as "orphans"

Related issue
closes #11967

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@ndeloof ndeloof requested review from a team, glours and jhrotko and removed request for a team July 8, 2024 08:17
@ndeloof ndeloof force-pushed the setEnvWithDotEnv branch 4 times, most recently from 258b86e to 68d5d03 Compare July 8, 2024 14:45
Signed-off-by: Nicolas De Loof <[email protected]>
// isOrphaned is a predicate to select containers without a matching service definition in compose project
func isOrphaned(project *types.Project) containerPredicate {
services := append(project.ServiceNames(), project.DisabledServiceNames()...)
return func(c moby.Container) bool {
// One-off container
v, ok := c.Labels[api.OneoffLabel]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what is the oneOffLabel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used to distinguish containers created by docker compose run vs actual services created by up

@@ -37,7 +37,7 @@ func TestLocalComposeRun(t *testing.T) {
"Hello one more time")
lines = Lines(res.Stdout())
assert.Equal(t, lines[len(lines)-1], "Hello one more time", res.Stdout())
assert.Assert(t, !strings.Contains(res.Combined(), "orphan"))
assert.Assert(t, strings.Contains(res.Combined(), "orphan"))
Copy link
Contributor

@jhrotko jhrotko Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: was this a bug before your chnages? :o

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more or less. We only considered "orphans" for service container not declared in current compose model. This PR also consider stopped run containers as orphaned

Copy link
Contributor

@jhrotko jhrotko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours glours merged commit d3d378b into docker:main Jul 11, 2024
30 checks passed
@ndeloof ndeloof deleted the setEnvWithDotEnv branch July 11, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] 2.28.1 multiple COMPOSE_* vars no longer read from .env file
3 participants