diff options
author | Qi Wang <qiwan@redhat.com> | 2020-07-01 10:43:44 -0400 |
---|---|---|
committer | Qi Wang <qiwan@redhat.com> | 2020-07-03 15:29:38 -0400 |
commit | 4192298be3e55207ca983c21f357029df9765c56 (patch) | |
tree | 3199b0728c20f70fbd355d1ba282f515ea17912b | |
parent | bd2fca06090f8138b4f770b753adc05c28912d6f (diff) | |
download | podman-4192298be3e55207ca983c21f357029df9765c56.tar.gz podman-4192298be3e55207ca983c21f357029df9765c56.tar.bz2 podman-4192298be3e55207ca983c21f357029df9765c56.zip |
Set engine env from common config
Set the env that is used by Podman.
related issue containers/common#31
Signed-off-by: Qi Wang <qiwan@redhat.com>
-rw-r--r-- | cmd/podman/root.go | 15 | ||||
-rw-r--r-- | docs/source/markdown/podman.1.md | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 45ca48c39..3bb45f806 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -128,6 +128,21 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { return err } + for _, env := range cfg.Engine.Env { + splitEnv := strings.SplitN(env, "=", 2) + if len(splitEnv) != 2 { + return fmt.Errorf("invalid environment variable for engine %s, valid configuration is KEY=value pair", env) + } + // skip if the env is already defined + if _, ok := os.LookupEnv(splitEnv[0]); ok { + logrus.Debugf("environment variable %s is already defined, skip the settings from containers.conf", splitEnv[0]) + continue + } + if err := os.Setenv(splitEnv[0], splitEnv[1]); err != nil { + return err + } + } + if cmd.Flag("cpu-profile").Changed { f, err := os.Create(cfg.CPUProfile) if err != nil { diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md index ce02ef3a7..c45c10243 100644 --- a/docs/source/markdown/podman.1.md +++ b/docs/source/markdown/podman.1.md @@ -123,6 +123,10 @@ NOTE --tmpdir is not used for the temporary storage of downloaded images. Use t Print the version +## Environment Variables + +Podman can set up environment variables from env of [engine] table in containers.conf. These variables can be overridden by passing environment variables before the `podman` commands. + ## Exit Status The exit code from `podman` gives information about why the container |