diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index d69677b05..0527ebfe9 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -44,7 +44,7 @@ func main() { // traefik config inits tConfig := cmd.NewTraefikConfiguration() - loaders := []cli.ResourceLoader{&cli.FileLoader{}, &cli.EnvLoader{}, &cli.FlagLoader{}} + loaders := []cli.ResourceLoader{&cli.FileLoader{}, &cli.FlagLoader{}, &cli.EnvLoader{}} cmdTraefik := &cli.Command{ Name: "traefik", diff --git a/docs/content/getting-started/configuration-overview.md b/docs/content/getting-started/configuration-overview.md index c06a6bb0f..864b5dc2c 100644 --- a/docs/content/getting-started/configuration-overview.md +++ b/docs/content/getting-started/configuration-overview.md @@ -36,8 +36,8 @@ Traefik gets its _dynamic configuration_ from [providers](../providers/overview. There are three different, mutually exclusive, ways to define static configuration options in Traefik: - In a configuration file -- As environment variables - In the command-line arguments +- As environment variables These ways are evaluated in the order listed above. diff --git a/pkg/cli/loader_env.go b/pkg/cli/loader_env.go index e1f015638..07e40faa4 100644 --- a/pkg/cli/loader_env.go +++ b/pkg/cli/loader_env.go @@ -3,6 +3,7 @@ package cli import ( "fmt" "os" + "strings" "github.com/containous/traefik/pkg/config/env" "github.com/containous/traefik/pkg/log" @@ -19,7 +20,8 @@ func (e *EnvLoader) Load(_ []string, cmd *Command) (bool, error) { } if err := env.Decode(vars, env.DefaultNamePrefix, cmd.Configuration); err != nil { - return false, fmt.Errorf("failed to decode configuration from environment variables: %v", err) + log.WithoutContext().Debug("environment variables", strings.Join(vars, ", ")) + return false, fmt.Errorf("failed to decode configuration from environment variables: %v ", err) } log.WithoutContext().Println("Configuration loaded from environment variables.") diff --git a/pkg/cli/loader_flag.go b/pkg/cli/loader_flag.go index cb529a9f4..fcf2b3076 100644 --- a/pkg/cli/loader_flag.go +++ b/pkg/cli/loader_flag.go @@ -12,6 +12,10 @@ type FlagLoader struct{} // Load loads the command's configuration from flag arguments. func (*FlagLoader) Load(args []string, cmd *Command) (bool, error) { + if len(args) == 0 { + return false, nil + } + if err := flag.Decode(args, cmd.Configuration); err != nil { return false, fmt.Errorf("failed to decode configuration from flags: %v", err) }