docker { logs } returns no lines for containers that log to stderr

Abierto Apto para principiantes
#2,150 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, typescript
Área
backend

Línea de trabajo

Empieza con DockerLogService.getContainerLogs en api/src/unraid-api/graph/resolvers/docker/docker-log.service.ts, donde el issue indica que solo se lee stdout del comando docker. Comprueba cómo el resolver analiza y ordena las líneas con marca de tiempo y, después, verifica que la consulta también devuelve la salida de stderr, incluida la reproducción proporcionada con un contenedor que solo escribe en stderr.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Environment

Unraid OS Version:
7.4.0 (API 4.37.11+8e587fe2)

Are you using a reverse proxy?
Yes (NPMPlus). I reproduced the issue directly on the server through the API's unix socket (/var/run/unraid-api.sock), without the proxy. The result is the same.

Pre-submission Checklist

  • I have verified that my Unraid OS is up to date
  • I have tested this issue by accessing my server directly (not through a reverse proxy)
  • This is not an Unraid Connect related issue (if it is, please submit via the support form instead)

Issue Description

The docker { logs } query returns an empty lines list and no error for a container that writes its log output to stderr. Containers that log to stdout return their lines as expected.

A client therefore cannot tell "the container logged nothing" from "the container logs to stderr", which is the default for Python's logging and many Go services.

Steps to Reproduce

  1. Start a container that only writes to stderr:

    docker run -d --name stderr-test alpine sh -c 'while true; do echo "to stderr" >&2; sleep 5; done'
    
  2. Check on the host that the output is on stderr only:

    # docker logs --tail 3 stderr-test
    to stderr
    to stderr
    to stderr
    # docker logs --tail 3 stderr-test 2>/dev/null
    #
    
  3. Look up the container id with query { docker { containers { id names } } } and request its logs, directly on the server:

    curl -s --unix-socket /var/run/unraid-api.sock http://localhost/graphql \
      -H "x-api-key: $KEY" -H "Content-Type: application/json" \
      -d '{"query":"{ docker { logs(id: \"<id>\", tail: 3) { lines { timestamp message } } } }"}'
    

Expected Behavior

The lines from both stdout and stderr, ordered by timestamp, as docker logs shows them.

Actual Behavior

{"data":{"docker":{"logs":{"lines":[]}}}}

No lines and no error. The same happens without tail and with since. On the same server, containers that log to stdout (for example jellyfin, pihole, redis) return lines through the same query.

Additional Context

DockerLogService.getContainerLogs in api/src/unraid-api/graph/resolvers/docker/docker-log.service.ts reads only stdout:

const { stdout } = await execa('docker', args);

docker logs writes the container's stderr stream to its own stderr, so that stream is dropped. The line is the same in v4.30.0, v4.35.0, v4.37.5, v4.37.11 and on main, so this is not a regression of 7.4.0.

Reading both streams would fix it, for example with execa's all: true and parsing all instead of stdout. --timestamps is already passed, so the lines can be put in order.

I searched open and closed issues and pull requests for an existing report and found none.

I first noticed this with a real container (unbound) and tracked it down with the help of an AI assistant. I ran the reproduction above myself on the server.

Lenguaje dominante
TypeScript
Estrellas
123
Forks
25
Merge medio
2 d 16 h
PR fusionados (30 d)
9

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de unraid/api

Todos los issues de unraid/api

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.