Icanup
docker-inspect-running-container-environment-variables-tip.png
Швидка порадаDocker

Docker: Inspect Environment Variables of a Running Container

Use docker inspect to see the actual environment variables configured in a running container instead of relying only on values from a local .env file.

When debugging Docker, it is important to distinguish configuration stored in .env from the configuration of a container that is already running.

If the container was created earlier, changing .env does not mean the running container is already using the new values.

Inspect the Container Environment Variables

BASH - Show all environment variables
docker inspect container-name \  --format '{{range .Config.Env}}{{println .}}{{end}}'

The command reads .Config.Env directly from the container configuration and prints each variable on a separate line.

For example:

BASH - Example output
APP_ENV=localAPP_DEBUG=trueREDIS_HOST=redisCACHE_DRIVER=redis

Filter One Specific Variable

BASH - Filter one variable
docker inspect container-name \  --format '{{range .Config.Env}}{{println .}}{{end}}' \  | grep '^REDIS_HOST='

This is useful when you only need to confirm one host, port, mode, or another specific value without scanning the entire environment.

Environment variables may contain passwords, tokens, and other secrets. Do not copy the full docker inspect output into public logs, screenshots, or documentation.

In short: .env shows the intended configuration, while docker inspect shows the configuration used by the actual container that was created and is running.

#docker #docker-inspect #docker-compose #environment-variables #debugging

Схожі поради

docker-find-actual-host-port-tip.pngПорада
Переглянути пораду
#laradock #docker #docker-port #port-mapping #docker-compose
laradock-minio-find-console-url-credentials-tip.pngПорада
Переглянути пораду
#minio #laradock #docker #docker-inspect