mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Merge pull request #1682 from ndeloof/exec_env
define exec env by merging service env with command line --env
This commit is contained in:
commit
ccaa1754d4
@ -49,9 +49,18 @@ func (s *composeService) Exec(ctx context.Context, project *types.Project, opts
|
|||||||
}
|
}
|
||||||
container := containers[0]
|
container := containers[0]
|
||||||
|
|
||||||
|
var env []string
|
||||||
|
projectEnv := types.NewMappingWithEquals(opts.Environment).Resolve(func(s string) (string, bool) {
|
||||||
|
v, ok := project.Environment[s]
|
||||||
|
return v, ok
|
||||||
|
})
|
||||||
|
for k, v := range service.Environment.OverrideBy(projectEnv) {
|
||||||
|
env = append(env, fmt.Sprintf("%s=%s", k, *v))
|
||||||
|
}
|
||||||
|
|
||||||
exec, err := s.apiClient.ContainerExecCreate(ctx, container.ID, apitypes.ExecConfig{
|
exec, err := s.apiClient.ContainerExecCreate(ctx, container.ID, apitypes.ExecConfig{
|
||||||
Cmd: opts.Command,
|
Cmd: opts.Command,
|
||||||
Env: opts.Environment,
|
Env: env,
|
||||||
User: opts.User,
|
User: opts.User,
|
||||||
Privileged: opts.Privileged,
|
Privileged: opts.Privileged,
|
||||||
Tty: opts.Tty,
|
Tty: opts.Tty,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user