Skip to content

feat(docker): add bounded container log file tail reads - #5785

Draft
VijinV wants to merge 1 commit into
Dokploy:canaryfrom
VijinV:codex/container-file-log-tail
Draft

VijinV wants to merge 1 commit into
Dokploy:canaryfrom
VijinV:codex/container-file-log-tail

Conversation

@VijinV

@VijinV VijinV commented Oct 26, 2026

Copy link
Copy Markdown

Applications can write logs to files instead of stdout/stderr. The existing editor reads a bounded prefix, which can hide the newest errors. This adds a separate read-only docker.readContainerFileTail endpoint that returns the newest lines in chronological order.

Related: #5703 and the open implementation in #5704. This is an alternative for maintainer review, kept separate from #5194.

  • Defaults to 200 lines and 64 KiB; validates positive integer limits up to 5,000 lines and 512 KiB.
  • Executes tail with an argument array through Dockerode, applying the byte window before line selection. No shell pipeline or whole-file buffering is used, including on saved SSH servers.
  • Returns UTF-8 text with truncated, truncatedByBytes and truncatedByLines metadata. Split leading UTF-8 bytes are skipped; invalid text fails explicitly instead of expanding past the byte cap through replacement characters.
  • Checks regular-file metadata before execution; rejects symlinks, FIFOs, devices and directories. Handles missing files/containers, failed reads and unavailable tail utilities explicitly.
  • Applies a 10-second caller deadline and bounded stdout/stderr collectors. Preserves docker.read authorization and remote-server organization checks.

Validation: 63 tests pass under Node 24.22.1, including 8 real Linux Docker integration tests for an EOF marker beyond 512 KiB, a 2 MiB line, Unicode, unusual filenames, special-file rejection and missing files. Other tests cover limits, timeouts, output overflow, local/remote clients and actual tRPC authorization. App TypeScript and Biome checks pass. Opt in to integration tests with DOKPLOY_DOCKER_INTEGRATION=1; the suite creates and removes its own temporary container using node:24-alpine.

Limitations: this requires a tail utility and Docker archive metadata access for the selected regular file. The deadline closes caller I/O; Docker exec does not offer a portable way to kill a process blocked by unresponsive storage or a concurrent file replacement. It adds snapshot reads only.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant