fix(jsonfile): Create per-container log directory before opening log file - #394
Merged
Merged
Conversation
…file The json-file driver receives a log path whose parent directory may not exist yet. Without this fix, dockerjsonfilelog.New() fails with "no such file or directory" and the container exits immediately. Add os.MkdirAll on the parent directory of the log path before opening the file. The directory is created with mode 02750 (setgid + owner rwx, group rx) so that subdirectories and files inherit the parent's group ownership when the parent has the setgid bit set.
aaithal
force-pushed
the
fix-jsonfile-mkdir-logdir
branch
from
June 18, 2026 05:19
925ffdb to
ea068fe
Compare
singholt
approved these changes
Jun 18, 2026
xxx0624
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of changes:
The json-file driver receives a log path whose parent directory may not exist yet. When
dockerjsonfilelog.New()attempts to open the file, it fails with "no such file or directory" because the per-container subdirectory has not been created.This change adds
os.MkdirAllon the parent directory of the log path before opening the file. The directory is created with mode 02750 (setgid + owner rwx, group rx) so that files and subdirectories inherit the parent's group ownership when the parent has the setgid bit set.Includes unit tests for directory creation and idempotency, and an e2e test that verifies the shim-logger creates the directory when it does not exist.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.