liveBook · Manning

Environment variable

As explained in Quarkus in Action

An environment variable is a named configuration value supplied through a process or container execution environment.

An environment variable is a named configuration value supplied through a process or container environment. Containers and Kubernetes use environment variables to override instance-specific settings, such as unique identifiers, without rebuilding the application artifact. section 1.2.1

In Quarkus, environment variables provide a runtime configuration layer above application.properties. Configuration precedence is system properties first, environment variables second, and application.properties third. section 3.2.3

Map application configuration to environment variables by following these rules:

  • Capitalize the property name. section 3.2.3
  • Replace each dot delimiter with an underscore; for example, my.greeting becomes MY_GREETING. section 3.2.3
  • Set the variable when starting the process or container so the same artifact can receive environment-specific values. section 1.2.1 section 3.2.3

Override a greeting in Dev mode

Run GREETING="Environment variable value" quarkus dev. With no system-property override, Quarkus uses this value instead of the greeting configured in application.properties. If -Dgreeting="System property value" is also supplied, the system property wins.

The Dev UI can display environment variables and system properties alongside application configuration. Editing a value there persists it to application.properties, but that file is not automatically translated into System.getenv(); application code should read configuration through the MicroProfile Config API. section 3.3.1

Figure 1.2 Visualizing the relationships between the application, container, and Kubernetes
figure

Use the application-container-Kubernetes relationship to trace where runtime configuration enters a deployed service. section 1.2.1

How Quarkus in Action covers it

How deep it goes
Explains runtime precedence, naming conversion, commands, and API distinctions without detailing container orchestration manifests.
Examples
Demonstrates GREETING in Quarkus Dev mode and contrasts environment-variable and system-property precedence.
What it assumes
Assumes basic process or container startup knowledge while introducing configuration precedence and environment-variable naming from the examples.
What you can do after
Apply it via Quarkus by overriding application.properties values at process startup and reading configuration through MicroProfile Config.
How it connects
Connects environment variables with containers, Kubernetes, Quarkus configuration, system properties, application.properties, and MicroProfile Config.

Also explained in

Compare how 19 books explain environment variable →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.