update_container ignores pull errors that Docker returns as HTTP error and recreates the container from the old image

Aperta
#2,816 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@luuvasara ci sta già lavorando.

Dal 11/11/2026.

  • #2817 di @luuvasara — aperta
  • #2839 di @luuvasara — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, php
Ambito
devops

Direzione di ricerca

Start with DockerClient::getDockerJSON() and pullImage() in include/DockerClient.php, then inspect pullImage_nchan() and the update flow in scripts/update_container. Trace how HTTP status and Docker's message response reach the update log and exit status. Done means failed pulls leave the existing container untouched, report the error, and make the script exit nonzero; verify with the unreachable registry response described in the issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Unraid version: 7.2.3 (same code in current master)

Describe the bug
If docker pull fails before the download starts (registry timeout, TLS handshake timeout, DNS or auth error), update_container does not notice. It stops and removes the container, recreates it from the image that is still on disk, shows no error and exits with code 0.

Real error that triggers it (from docker pull on the same host, same night):

Error response from daemon: Get "https://lscr.io/v2/": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Error response from daemon: Get "https://lscr.io/v2/": net/http: TLS handshake timeout

Root cause

  • DockerClient::getDockerJSON() reads the HTTP status into $code, but pullImage() never looks at it
  • pullImage_nchan() in scripts/update_container only fails on an error key in the streamed lines
  • Docker only streams {"error": ...} after the response has started. Errors before that (moby image_routes.go: if !output.Flushed() { return err }) come back as HTTP 500 with a body {"message": "..."}. There is no error key, so pullImage_nchan() returns true

To reproduce
What Docker returns for an unreachable registry:

$ curl -si --unix-socket /var/run/docker.sock -X POST 'http://localhost/images/create?fromImage=registry.invalid/foo/bar:latest'
HTTP/1.1 500 Internal Server Error
...
{"message":"Get \"https://registry.invalid/v2/\": dial tcp: lookup registry.invalid on 192.168.9.3:53: no such host"}

Same check that pullImage_nchan() does, without touching any container:

<?php
require_once '/usr/local/emhttp/plugins/dynamix.docker.manager/include/DockerClient.php';
$c = new DockerClient(); $strError = '';
$c->pullImage('registry.invalid/foo/bar:latest', function ($line) use (&$strError) {
  $cnt = json_decode($line, true);
  if (isset($cnt['error'])) $strError = $cnt['error'];
});
echo empty($strError) ? "treated as success\n" : "error: $strError\n";

Output on 7.2.3: treated as success

Full path: a container with an update available whose registry is unreachable at that moment (e.g. lscr.io timing out) → apply update or update_container <name>.

Expected behavior

  • The pull error is shown in the update log
  • The container is NOT stopped, removed or recreated
  • The script exits with a non-zero code, so callers (e.g. the Appdata Backup plugin) can detect the failure

Actual behavior

  • No error is shown
  • The container is stopped, removed and recreated from the old image (needless downtime)
  • Exit code 0. Callers report the update as successful

Real-world impact
The nightly auto-update (Appdata Backup plugin, which calls update_container) ran for swag without any error, but the container stayed on an old image with a known PHP vulnerability. A plain docker pull at the same time of night later failed with the lscr.io timeouts above, which matches this path.

Suggested fix
In pullImage() / pullImage_nchan() treat a non-2xx $code as failure and show the message field. Exit non-zero from update_container when any pull failed.

Lingua principale
PHP
Stelle
266
Fork
116
Merge medio
1g 5h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di unraid/webgui

Tutte le issue di unraid/webgui

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.