liveBook · Manning

Viper

As explained in Learn Docker in a Month of Lunches, Second Edition

Viper is a Go configuration library that loads settings from files and environment variables with precedence and override support.

Viper is a Go configuration library for combining settings from packaged files, environment-specific files, and environment variables. Files in the config directory provide defaults; files in config-override can be mounted into a container; environment variables take precedence. section 18.3

A practical container configuration workflow uses:

  • A default TOML file packaged in the Docker image. section 18.3
  • A config-override directory supplied through a container filesystem mount for environment-specific values. section 18.3
  • Environment variables that override both file-based settings. section 18.3

Inspecting merged configuration

Run the image with its defaults, then query its configuration API. Mount a development override directory and query again; finally set IG_METRICS.ENABLED=TRUE to verify environment-variable precedence.

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains configuration precedence and demonstrates container checks, but stops short of Viper API code.
Examples
Uses an image gallery, TOML settings, bind mounts, curl, and an IG_METRICS.ENABLED override.
What it assumes
Assumes basic Go and Docker workflows while introducing configuration layering and TOML from the practical example.
What you can do after
Operate/configure a Go container by layering default files, mounted environment overrides, and environment variables.
How it connects
Connects configuration files, environment variables, Docker containers, TOML, JSON, and YAML.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.