diff --git a/docs/command-reference.md b/docs/command-reference.md index 4f7a314678a..628a1e50b9e 100644 --- a/docs/command-reference.md +++ b/docs/command-reference.md @@ -1391,6 +1391,7 @@ Flags: - :whale: `-p, --project-name`: Specify an alternate project name - :nerd_face: `--ipfs-address`: Multiaddr of IPFS API (default uses `$IPFS_PATH` env variable if defined or local directory `~/.ipfs`) - :whale: `--profile: Specify a profile to enable +- :whale: `--env-file` : Specify an alternate environment file ### :whale: nerdctl compose up diff --git a/pkg/composer/up_service.go b/pkg/composer/up_service.go index 7bd6ea48c92..85010f25ce9 100644 --- a/pkg/composer/up_service.go +++ b/pkg/composer/up_service.go @@ -175,6 +175,10 @@ func (c *Composer) upServiceContainer(ctx context.Context, service *serviceparse defer os.RemoveAll(tempDir) cidFilename := filepath.Join(tempDir, "cid") + if c.EnvFile != "" { + container.RunArgs = append([]string{"--env-file=" + c.EnvFile}, container.RunArgs...) + } + //add metadata labels to container https://github.com/compose-spec/compose-spec/blob/master/spec.md#labels container.RunArgs = append([]string{ "--cidfile=" + cidFilename,