skip to Main Content

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


  1. Short answer: you should be able to set the LOG_LEVEL using an environment variable called REGISTRY_LOG_LEVEL:

    docker run -d -p 5000:5000 --restart=always --name registry -e REGISTRY_LOG_LEVEL=debug registry:2
    

    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:

    To override a configuration option, create an environment variable
    named REGISTRY_variable where variable is the name of the
    configuration option and the _ (underscore) represents indention
    levels. For example, you can configure the rootdirectory of the
    filesystem storage backend:

    storage:
      filesystem:
        rootdirectory: /var/lib/registry 
    

    To override this value, set an environment variable like this:

    REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/somewhere
    

    This variable overrides the /var/lib/registry value to the /somewhere directory.

    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 your docker run command, it’d look very similar to what you had before:

    docker run -d -p 5000:5000 --restart=always --name registry -e REGISTRY_LOG_LEVEL=debug registry:2
    
    Login or Signup to reply.
  2. The correct version is your second scenario with -e REGISTRY_LOG_LEVEL=debug:

    docker run --rm -p 5001:5000 -e REGISTRY_LOG_LEVEL=debug registry:2
    

    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:

    $ docker run --rm -p 5001:5000 -e REGISTRY_LOG_LEVEL=debug registry:2
    time="2023-12-24T12:27:31.556627862Z" 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.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry version="v2.8.1+unknown" 
    time="2023-12-24T12:27:31.55666679Z" level=info msg="redis not configured" go.version=go1.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry version="v2.8.1+unknown" 
    time="2023-12-24T12:27:31.556724277Z" level=info msg="Starting upload purge in 19m0s" go.version=go1.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry version="v2.8.1+unknown" 
    time="2023-12-24T12:27:31.563643382Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry version="v2.8.1+unknown" 
    time="2023-12-24T12:27:31.563766934Z" level=info msg="listening on [::]:5000" go.version=go1.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry version="v2.8.1+unknown" 
    time="2023-12-24T12:27:41.564927353Z" level=debug msg="filesystem.Stat("/")" go.version=go1.16.15 instance.id=7d6185c4-16b5-4b69-99f1-03a82988b830 service=registry trace.duration=137.428µs trace.file="/go/src/github.com/docker/distribution/registry/storage/driver/base/base.go" trace.func="github.com/docker/distribution/registry/storage/driver/base.(*Base).Stat" trace.id=b5fa783c-dbb9-4178-8213-1b3a09225973 trace.line=155 version="v2.8.1+unknown" fc00:1000::1 - - [24/Dec/2023:12:27:42 +0000] "GET /v2/ HTTP/1.1" 200 2 "" "docker/24.0.7 go/go1.20.10 git-commit/311b9ff kernel/5.10.0-19-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/24.0.7 \(linux\))"
    time="2023-12-24T12:27:42.701411636Z" level=debug msg="authorizing request" go.version=go1.16.15 http.request.host="localhost:5001" http.request.id=3bbd2d52-06a2-4b15-a0b7-9a4572952bde http.request.method=GET http.request.remoteaddr="[fc00:1000::1]:48298" http.request.uri="/v2/" http.request.useragent="docker/24.0.7 go/go1.20.10 git-commit/311b9ff kernel/5.10.0-19-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/24.0.7 (linux))" 
    time="2023-12-24T12:27:42.701489002Z" level=info msg="response completed" go.version=go1.16.15 http.request.host="localhost:5001" http.request.id=3bbd2d52-06a2-4b15-a0b7-9a4572952bde http.request.method=GET http.request.remoteaddr="[fc00:1000::1]:48298" http.request.uri="/v2/" http.request.useragent="docker/24.0.7 go/go1.20.10 git-commit/311b9ff kernel/5.10.0-19-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/24.0.7 (linux))" http.response.contenttype="application/json; charset=utf-8" http.response.duration=1.829974ms http.response.status=200 http.response.written=2 
    time="2023-12-24T12:27:42.70634826Z" level=debug msg="authorizing request" go.version=go1.16.15 http.request.host="localhost:5001" http.request.id=5d881a0d-1deb-4f72-8396-8efb187485a6 http.request.method=HEAD http.request.remoteaddr="[fc00:1000::1]:48300" http.request.uri="/v2/no-such-image/manifests/latest" http.request.useragent="docker/24.0.7 go/go1.20.10 git-commit/311b9ff kernel/5.10.0-19-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/24.0.7 (linux))" vars.name=no-such-image vars.reference=latest 
    time="2023-12-24T12:27:42.706462527Z" level=debug msg=GetImageManifest go.version=go1.16.15 http.request.host="localhost:5001" http.request.id=5d881a0d-1deb-4f72-8396-8efb187485a6 http.request.method=HEAD http.request.remoteaddr="[fc00:1000::1]:48300" http.request.uri="/v2/no-such-image/manifests/latest" http.request.useragent="docker/24.0.7 go/go1.20.10 git-commit/311b9ff kernel/5.10.0-19-amd64 os/linux arch/amd64 UpstreamClient(Docker-Client/24.0.7 (linux))" vars.name=no-such-image vars.reference=latest
    ...
    

    Those logs were generated by running the following after starting the registry:

    $ docker pull localhost:5001/no-such-image
    Using default tag: latest
    Error response from daemon: manifest for localhost:5001/no-such-image:latest not found: manifest unknown: manifest unknown
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search