With containrrr/watchtower, Getting 401 and config.json not found

615 Views Asked by At

I'm 99.9% sure I have the correct file automatically created on my Linux VM at the location /root/.docker/config.json.

It has the following values with the key x'd out.

{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "xxxxxx"
                }
        }
}

I get the error below on all my private containers. I was hoping I could log in in with docker exec -it, but there doesn't seem to be any shell in the container. Otherwise, I could look at /config and see if the file is there.

time="2023-03-20T21:13:07Z" level=debug msg="Trying to load authentication credentials." container=/svccrscproxy image="pkellner/svccuppercaseproxy:latest"
time="2023-03-20T21:13:07Z" level=debug msg="No credentials for pkellner found" config_file=/config.json

My launch is this:

services:

  watchtower:
    image: index.docker.io/containrrr/watchtower:latest
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/timezone:/etc/timezone:ro
      - /root/.docker/config.json:/config.json
    environment:
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_LABEL_ENABLE=false
      - WATCHTOWER_INCLUDE_RESTARTING=true
      - WATCHTOWER_DEBUG=true
      - WATCHTOWER_TRACE=true
      - WATCHTOWER_POLL_INTERVAL=30

    labels:
      - "com.centurylinklabs.watchtower.enable=true"
1

There are 1 best solutions below

0
bes On
$ docker login private-docker-registry.example.com

First and only time we need to log in to our local registry (do not forget to specify the port). If successful, your authorization will be written to local /root/.docker/config.json, which must be mapped inside the container so that it can read them.

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /root/.docker/config.json:/config.json containrrr/watchtower --run-once --cleanup --debug

Debugging a one-time watchtower run where we will see level=debug msg="Credentials loaded"

https://containrrr.dev/watchtower/usage-overview/