The "GREETING" variable is not set. Defaulting to a blank string. means your Compose file uses ${GREETING} and Compose found no value for it in the shell or in a .env file next to the Compose file. It is a warning: the project still starts, with an empty value. Put the value in .env, pass --env-file, or write a default into the file.

If the value must never be empty, use ${GREETING:?message} instead and Compose refuses to start without it. All four forms are shown below as they ran.

The error

PS> docker compose up
time="2026-11-06T12:54:16+05:30" level=warning msg="The \"GREETING\" variable is not set. Defaulting to a blank string."
...

The stack then started and the container printed greeting=. The file:

name: fix8-cli-v3
services:
  web:
    image: alpine
    command: ["echo", "greeting=${GREETING}"]

Why it happens

Compose replaces ${NAME} in the file before it starts anything. The PowerShell session had no GREETING variable, and the folder in the test held only compose.yaml, the two variants below and a test.env, so no value was found, the warning appeared, and the container printed greeting= with nothing after it.

The trap is that a warning scrolls past and the stack starts anyway, so the empty value reaches the container, as greeting= showed. Note that test.env sat in the same folder the whole time and was not read until it was passed with --env-file; the plain run picked up a file only once it was named .env.

The fix

A .env file next to the Compose file:

PS> type .env
GREETING=from-dot-env
PS> docker compose up
web-1  | greeting=from-dot-env

Another file, named on the command line:

PS> docker compose --env-file test.env up
web-1  | greeting=from-test-env

A default in the file, ${GREETING:-hello}:

PS> docker compose -f compose.default.yaml up
web-1  | greeting=hello

A required value, ${GREETING:?set GREETING in .env}, with no value set:

PS> docker compose -f compose.required.yaml up
error while interpolating services.web.command.[]: required variable GREETING is missing a value: set GREETING in .env

The up outputs are trimmed to the container's line. Use :- for values that have a sensible default and :? for secrets and connection strings, where starting with an empty value is worse than not starting.

How it was reproduced

Docker Desktop on Windows 11, engine 29.9.2, Docker Compose v5.6.1, Windows PowerShell 5.1 with no GREETING variable in the session, the cached alpine:latest image. The runs were made in one folder in this order: the plain run, --env-file, the default, the required form, and last the run with the .env file, which was created just before it. The project name fix8-cli-v3 is the test's own.

Frequently asked

How do I fix variable is not set. Defaulting to a blank string in docker compose?
Give the variable a value: a line NAME=value in a .env file next to the Compose file, docker compose --env-file <file>, or a default written into the file as ${NAME:-default}.
Does docker compose read any .env-like file automatically?
No. In this test only a file named .env was picked up without options; test.env in the same folder was used only when passed with --env-file.
How do I make docker compose fail when a variable is missing?
Write ${NAME:?message}. Compose then stops before starting anything and prints required variable NAME is missing a value followed by your message.

More decoded errors in the Fixes category.