App crashes: a required secret is set but empty
Easy

Problem

api won't stay up — it exits 1 right after boot. The deploy was careful to pass every environment variable the app needs, and the logs even say JWTSECRET present. Yet it still dies complaining about JWTSECRET. Figure out what's actually wrong with the config and get api running.

Initial setup

  • apimyapp:latest, Exited (1), deployed with JWT_SECRET,
DATABASE_URL, and PORT in its environment.

Example interaction

$ docker logs api
[config] JWT_SECRET present
RuntimeError: JWT_SECRET must be set to a non-empty value

$ docker inspect -f '{{.Config.Env}}' api
[JWT_SECRET= DATABASE_URL=postgresql://app@db:5432/appdb PORT=8080]

Acceptance

You've solved it when:

  • You've established the secret is present but empty (JWT_SECRET= with
no value) — not missing, not a bad password, not a DB problem. The deploy set the variable but the value resolved to the empty string (e.g. an unset ${JWT_SECRET} in the shell that ran compose).
  • You've brought api up running by supplying a real, non-empty
JWT_SECRET.

Constraints

  • Tools: docker CLI only.
  • End state: api in status == running with a non-empty JWT_SECRET.

Follow-up

  1. Why does a "the variable is present" check pass while the app still
fails — what's the difference between unset and empty?
  1. In docker run -e JWTSECRET (no =value) vs -e JWTSECRET= — what
does each do to the container's environment?
  1. How would ${JWT_SECRET:?error} in a compose file have surfaced this at
deploy time instead of at runtime?
Live session
Code
SavedNo commands yet