Imagens Docker do Discourse não estão assinadas

Olá,

Estou tentando configurar o Discourse em uma nova máquina. Clonei o repositório discourse_docker e executei ./launcher rebuild app. (Pulei a etapa de bootstrap porque já possuía configurações anteriores).

A reconstrução resultou na seguinte saída:

WARNING: We are about to start downloading the Discourse base image
This process may take anywhere between a few minutes to an hour, depending on your network speed

Please be patient

ERRO[0001] Metadata for targets expired
ERRO[0002] Metadata for targets expired
/usr/bin/docker: Error: remote repository docker.io/discourse/base out-of-date: targets expired at Mon Nov 18 12:52:09 -0500 2019.
See '/usr/bin/docker run --help'.
Your Docker installation is not working correctly

See: https://meta.discourse.org/t/docker-error-on-bootstrap/13657/18?u=sam

Para encontrar a raiz do problema, verifiquei o comando executado e o executei no modo de debug:

/usr/bin/docker --debug run -i --rm -a stdout -a stderr discourse/base:2.0.20191219-2109 echo working

Veja: discourse_docker/launcher at 1b3dd3a41b544592be46b39db563bb757f88bbad · discourse/discourse_docker · GitHub

A saída do comando:
DEBU[0000] reading certificate directory: /root/.docker/tls/notary.docker.io
DEBU[0000] No yubikey found, using alternative key storage: no library found
DEBU[0000] Making dir path: /root/.docker/trust/tuf/docker.io/discourse/base/changelist
DEBU[0000] entered ValidateRoot with dns: docker.io/discourse/base
DEBU[0000] found the following root keys: [5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8]
DEBU[0000] found 1 valid leaf certificates for docker.io/discourse/base: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] found 1 leaf certs, of which 1 are valid leaf certs for docker.io/discourse/base
DEBU[0000] checking root against trust_pinning config for docker.io/discourse/base
DEBU[0000] checking trust-pinning for cert: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000]  role has key IDs: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] verifying signature for key ID: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] root validation succeeded for docker.io/discourse/base
DEBU[0000] entered ValidateRoot with dns: docker.io/discourse/base
DEBU[0000] found the following root keys: [5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8]
DEBU[0000] found 1 valid leaf certificates for docker.io/discourse/base: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] found 1 leaf certs, of which 1 are valid leaf certs for docker.io/discourse/base
DEBU[0000] checking root against trust_pinning config for docker.io/discourse/base
DEBU[0000] checking trust-pinning for cert: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000]  role has key IDs: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] verifying signature for key ID: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0000] root validation succeeded for docker.io/discourse/base
DEBU[0000] updating TUF client
DEBU[0000] Loading timestamp...
DEBU[0001] 200 when retrieving metadata for timestamp
DEBU[0001] timestamp role has key IDs: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0001] verifying signature for key ID: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0001] timestamp role has key IDs: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0001] verifying signature for key ID: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0001] successfully verified downloaded timestamp
DEBU[0001] Loading snapshot...
DEBU[0001] snapshot role has key IDs: e88a99d5b23301178976a4a103df4716f7943301d9972db0541bfa17c94cb75b
DEBU[0001] verifying signature for key ID: e88a99d5b23301178976a4a103df4716f7943301d9972db0541bfa17c94cb75b
DEBU[0001] successfully verified cached snapshot
DEBU[0001] Loading targets...
DEBU[0001] no targets in cache, must download
DEBU[0001] 200 when retrieving metadata for targets.09b50021560effa664eb8271cd16e2212ed55b7b63b2127cf9a0e69cfe2b47b7
DEBU[0001] targets role has key IDs: c016860a9293a48bc98f27b9c36d81515f4bcc3dd2ec93bb2d6d8af8f37a39d2
DEBU[0001] verifying signature for key ID: c016860a9293a48bc98f27b9c36d81515f4bcc3dd2ec93bb2d6d8af8f37a39d2
ERRO[0001] Metadata for targets expired
DEBU[0001] downloaded targets.09b50021560effa664eb8271cd16e2212ed55b7b63b2127cf9a0e69cfe2b47b7 is invalid: targets expired at Mon Nov 18 12:52:09 -0500 2019
DEBU[0001] Client Update (Targets): targets expired at Mon Nov 18 12:52:09 -0500 2019
DEBU[0001] Error occurred. Root will be downloaded and another update attempted
DEBU[0001] Resetting the TUF builder...
DEBU[0001] entered ValidateRoot with dns: docker.io/discourse/base
DEBU[0001] found the following root keys: [5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8]
DEBU[0001] found 1 valid leaf certificates for docker.io/discourse/base: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] found 1 leaf certs, of which 1 are valid leaf certs for docker.io/discourse/base
DEBU[0001] found the following root keys: [5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8]
DEBU[0001] found 1 valid leaf certificates for docker.io/discourse/base: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] found 1 valid root leaf certificates for docker.io/discourse/base: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001]  role has key IDs: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] verifying signature for key ID: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] checking root against trust_pinning config for docker.io/discourse/base
DEBU[0001] checking trust-pinning for cert: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001]  role has key IDs: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] verifying signature for key ID: 5f5ba22b20768b8f2d49e9035400a1922ae761aa70b5bb0d930fe91dd06bd5d8
DEBU[0001] root validation succeeded for docker.io/discourse/base
DEBU[0001] successfully verified cached root
DEBU[0001] retrying TUF client update
DEBU[0001] Loading timestamp...
DEBU[0002] 200 when retrieving metadata for timestamp
DEBU[0002] timestamp role has key IDs: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0002] verifying signature for key ID: db679e1f17a2a2bdd9952b6f37c9048635611f162bc6a0957ec30fbb1412d366
DEBU[0002] successfully verified downloaded timestamp
DEBU[0002] Loading snapshot...
DEBU[0002] snapshot role has key IDs: e88a99d5b23301178976a4a103df4716f7943301d9972db0541bfa17c94cb75b
DEBU[0002] verifying signature for key ID: e88a99d5b23301178976a4a103df4716f7943301d9972db0541bfa17c94cb75b
DEBU[0002] successfully verified cached snapshot
DEBU[0002] Loading targets...
DEBU[0002] no targets in cache, must download
DEBU[0002] 200 when retrieving metadata for targets.09b50021560effa664eb8271cd16e2212ed55b7b63b2127cf9a0e69cfe2b47b7
DEBU[0002] targets role has key IDs: c016860a9293a48bc98f27b9c36d81515f4bcc3dd2ec93bb2d6d8af8f37a39d2
DEBU[0002] verifying signature for key ID: c016860a9293a48bc98f27b9c36d81515f4bcc3dd2ec93bb2d6d8af8f37a39d2
ERRO[0002] Metadata for targets expired
DEBU[0002] downloaded targets.09b50021560effa664eb8271cd16e2212ed55b7b63b2127cf9a0e69cfe2b47b7 is invalid: targets expired at Mon Nov 18 12:52:09 -0500 2019
DEBU[0002] Client Update (Targets): targets expired at Mon Nov 18 12:52:09 -0500 2019
/usr/bin/docker: Error: remote repository docker.io/discourse/base out-of-date: targets expired at Mon Nov 18 12:52:09 -0500 2019.
See '/usr/bin/docker run --help'.

Não faço ideia do motivo disso acontecer. Verifiquei o histórico do git e reverti para a imagem base anteriormente utilizada para ver se funcionava. O resultado foi o mesmo.

Veja: Bump base image · discourse/discourse_docker@1b3dd3a · GitHub

Qualquer ajuda será bem-vinda :slight_smile:

Atualização #1

Criei um post no fórum do Docker para discutir esse problema, conforme sugerido por @Falco.

Você pode atualizar o Docker para a versão mais recente disponível para seu sistema operacional e tentar novamente?

Obrigado pela sua resposta, @Falco.

Estou executando a versão mais recente do Docker:

Docker version 19.03.5, build 633a0ea838

Veja: Docker Engine version 29 release notes | Docker Docs

Desculpe por não ter mencionado isso antes :roll_eyes:

Então um simples

docker pull discourse/base:2.0.20191219-2109

está falhando?

Sim. Este comando falha da mesma maneira descrita em minha postagem inicial:

ERRO[0001] Metadados para alvos expiraram
ERRO[0002] Metadados para alvos expiraram
Erro: repositório remoto docker.io/discourse/base desatualizado: alvos expiraram em Mon Nov 18 12:52:09 -0500 2019

Isso é muito estranho. O relógio do seu servidor está correto? Você tem algum cache, firewall ou algo assim estranho?

@Falco Meu relógio parece estar sincronizado:

$ timedatectl status

                      Hora local: Sex 2019-12-27 19:57:48 CET
                  Hora universal: Sex 2019-12-27 18:57:48 UTC
                        Hora RTC: Sex 2019-12-27 18:57:49
                       Fuso horário: Europe/Berlin (CET, +0100)
       Relógio do sistema sincronizado: sim
systemd-timesyncd.service ativo: sim
                 RTC no fuso local: não

Estou executando o Ubuntu 18.04 LTS.

Também quero mencionar que outros containers funcionam perfeitamente. Portanto, parece estar de alguma forma relacionado à imagem do Discourse.

Bem, consigo fazer docker pull discourse/base:2.0.20191219-2109 sem problemas, em vários sistemas operacionais, em diferentes provedores de nuvem e em diferentes continentes. Portanto, diria que se trata de algo específico do seu computador local ou da instalação do Docker.

Como isso vem do serviço docker, tente buscar ajuda em https://forums.docker.com/

Vou fazer, @Falco. Obrigado pela ajuda até agora :slight_smile:

@Falco Criei uma postagem nos fóruns do Docker e recebi uma resposta.

O problema está relacionado a DOCKER_CONTENT_TRUST=1.

Para reproduzir esse problema, execute os seguintes comandos:

$ export DOCKER_CONTENT_TRUST=1
$ docker pull discourse/base:2.0.20191219-2109

Ah, entendi. Por que você definiu essa flag na sua máquina local? Ela não vem habilitada por padrão no Ubuntu.

Estou configurando um servidor na internet. Isso não está na minha máquina local. O servidor deve ser “endurecido” e é por isso que esta opção está habilitada.

Também não vem ativado por padrão no Ubuntu Server.

Isso está correto, @Falco. Eu ativei. Pelo que pude constatar, as imagens do Discourse ou não estão assinadas corretamente ou não estão assinadas de forma alguma (estou investigando no momento).

De qualquer forma, seria desejável ter imagens/tags assinadas. Posso imaginar que não sou o único que usa DCT.

Faz parte de ferramentas de auditoria como o Docker Bench Security (veja abaixo):

4.5  - Garantir que a confiança de conteúdo para o Docker esteja ativada

Por enquanto, posso desativá-la, mas seria ótimo ter uma imagem/tag assinada também para as imagens do Discourse :slight_smile:

Devo criar uma solicitação de recurso para que possamos fechar esta issue?

Por enquanto, você está seguindo instruções diferentes de uma instalação recomendada, então isso será marcado como não suportado, para que outros não cometam o mesmo erro.