I am trying to change the log level of the docker registry while creating my registry container.
docker run -d -p 5000:5000 --restart=always --name registry -e LOG_LEVEL=debug registry:2
When I run the following command to view the logs it provides only info-level logs
docker logs registry
time="2023-12-21T20:07:44.13670802Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.20.8 instance.id=607dce47-0f7b-4959-9818-d859fc71a566 service=registry version=2.8.3
time="2023-12-21T20:07:44.136763361Z" level=info msg="redis not configured" go.version=go1.20.8 instance.id=607dce47-0f7b-4959-9818-d859fc71a566 service=registry version=2.8.3
time="2023-12-21T20:07:44.136831792Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.20.8 instance.id=607dce47-0f7b-4959-9818-d859fc71a566 service=registry version=2.8.3
time="2023-12-21T20:07:44.136998129Z" level=info msg="listening on [::]:5000" go.version=go1.20.8 instance.id=607dce47-0f7b-4959-9818-d859fc71a566 service=registry version=2.8.3
time="2023-12-21T20:07:44.137039251Z" level=info msg="Starting upload purge in 55m0s" go.version=go1.20.8 instance.id=607dce47-0f7b-4959-9818-d859fc71a566 service=registry version=2.8.3
I have also tried the following command but it still shows the info level
docker run -d -p 5000:5000 --restart=always --name registry -e REGISTRY_LOG_LEVEL=debug registry:2
2
Answers
Short answer: you should be able to set the
LOG_LEVEL
using an environment variable calledREGISTRY_LOG_LEVEL
:Long answer: While the maintainers’ guidance is generally to use a configuration file rather than modifying environment variables, the documentation does indicate it should be possible to modify the default configuration values without doing so by crafting a very specifically-named environment variable that corresponds with the hierarchy in which the configuration key/value pair falls:
Referring once more to the documentation page linked above, you’re probably looking to set an environment variable called
REGISTRY_LOG_LEVEL=debug
. In the context of yourdocker run
command, it’d look very similar to what you had before:The correct version is your second scenario with
-e REGISTRY_LOG_LEVEL=debug
:However, it doesn’t look like you are doing anything that would generate any debug logs. Note that turning on debug logging adds logs in addition to the info and warning levels, but there still needs to be some action that would generate a log:
Those logs were generated by running the following after starting the registry: