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

Đang mở Phù hợp với người mới
#2,150 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, typescript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với DockerLogService.getContainerLogs trong api/src/unraid-api/graph/resolvers/docker/docker-log.service.ts, nơi issue cho biết chỉ có stdout được đọc từ lệnh docker. Kiểm tra cách resolver phân tích và sắp xếp các dòng có dấu thời gian, sau đó xác minh rằng truy vấn cũng trả về đầu ra stderr, bao gồm cả trường hợp tái hiện được cung cấp với một container chỉ ghi vào stderr.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
123
Fork
25
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của unraid/api

Tất cả issue của unraid/api

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.