Fix: Collapse duplicate Docker progress lines in deployment logs #3322
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Before

After

Solution
Implemented a solution that:
Normalizes carriage returns: Converts
\r\n(Windows line endings) and standalone\r(progress updates) to\nfor consistent processing.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.
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.tscollapseProgressLines()function to detect and collapse Docker progress lines with the same image hashparseLogs()to normalize carriage returns and apply the collapse logic before parsing log linesTechnical Details
The solution uses a regex pattern to identify Docker progress lines:
/^([a-f0-9]{12})(\s+\[.*\].*)?$/ihash [progress]) and lines with just the hashWhen 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:
Impact
Notes