Skip to content

Conversation

@Pep3M
Copy link

@Pep3M Pep3M commented Dec 20, 2025

Problem

When Docker pulls images during deployment, the progress output uses ANSI control characters (specifically carriage return \r) to update the same line in the terminal. However, in the web interface, each update was being displayed as a separate line, resulting in hundreds of duplicate progress lines that made the logs unreadable.

Example of the issue:

8290a44abafc [>                                                  ]  143.8kB/14.36MB
8290a44abafc [=>                                                 ]  294.9kB/14.36MB
8290a44abafc [=>                                                 ]  442.4kB/14.36MB
8290a44abafc [==>                                                ]  737.3kB/14.36MB
... (hundreds more duplicate lines)

Before
before-ezgif com-video-to-gif-converter

After
after-ezgif com-video-to-gif-converter

Solution

Implemented a solution that:

  1. Normalizes carriage returns: Converts \r\n (Windows line endings) and standalone \r (progress updates) to \n for consistent processing.

  2. Collapses duplicate progress lines: Detects Docker progress lines (identified by a 12-character hexadecimal hash prefix) and replaces previous occurrences of the same hash with the latest update, preventing duplicate lines from appearing in the logs.

  3. Handles interleaved progress: When multiple images are being pulled simultaneously, the solution correctly tracks and updates each image's progress line independently by searching backwards through the log lines to find the last occurrence of each hash.

Changes Made

Modified Files

  • apps/dokploy/components/dashboard/docker/logs/utils.ts
    • Added collapseProgressLines() function to detect and collapse Docker progress lines with the same image hash
    • Modified parseLogs() to normalize carriage returns and apply the collapse logic before parsing log lines
    • Updated line processing to handle messages without timestamps (progress lines often don't have timestamps)

Technical Details

The solution uses a regex pattern to identify Docker progress lines:

  • Pattern: /^([a-f0-9]{12})(\s+\[.*\].*)?$/i
  • Detects lines starting with a 12-character hexadecimal hash (Docker image layer ID)
  • Matches both lines with progress bars (hash [progress]) and lines with just the hash

When a progress line is detected, the function searches backwards through the processed lines to find the last occurrence of the same hash and replaces it with the new update, effectively collapsing duplicates.

Testing

Tested with deployment logs that contain:

  • Multiple Docker image pulls with interleaved progress updates
  • Standard log lines with timestamps
  • Progress lines without timestamps
  • Mixed content (regular logs + progress updates)

Impact

  • ✅ Improves readability of deployment logs by removing duplicate progress lines
  • ✅ Maintains backward compatibility with existing log formats
  • ✅ Minimal code changes (surgical approach as requested)
  • ✅ No breaking changes to the log parsing logic

Notes

  • This fix specifically addresses the display issue in the web interface. The underlying log data structure remains unchanged.
  • The solution is focused and does not alter other parts of the logging system.
  • Regular log lines (with timestamps) continue to work exactly as before.

@Pep3M Pep3M requested a review from Siumauricio as a code owner December 20, 2025 17:50
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