Skip to content

Commit 07e7619

Browse files
ndeloofglours
authored andcommitted
set provider environment
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent ed81185 commit 07e7619

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/compose/plugins.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,15 @@ func (s *composeService) setupPluginCommand(ctx context.Context, project *types.
168168
args = append(args, service.Name)
169169

170170
cmd := exec.CommandContext(ctx, path, args...)
171-
// Remove DOCKER_CLI_PLUGIN... variable so plugin can detect it run standalone
172-
cmd.Env = filter(os.Environ(), manager.ReexecEnvvar)
171+
// exec provider command with same environment Compose is running
172+
env := types.NewMapping(os.Environ())
173+
// but remove DOCKER_CLI_PLUGIN... variable so plugin can detect it run standalone
174+
delete(env, manager.ReexecEnvvar)
175+
// and add the explicit environment variables set for service
176+
for key, val := range service.Environment.RemoveEmpty().ToMapping() {
177+
env[key] = val
178+
}
179+
cmd.Env = env.Values()
173180

174181
// Use docker/cli mechanism to propagate termination signal to child process
175182
server, err := socket.NewPluginServer(nil)

0 commit comments

Comments
 (0)