-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: add configurable detach delay to logs #5307
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5307 +/- ##
==========================================
- Coverage 61.45% 61.41% -0.05%
==========================================
Files 299 299
Lines 20856 20882 +26
==========================================
+ Hits 12818 12824 +6
- Misses 7122 7142 +20
Partials 916 916 |
96b7b32
to
a8844f8
Compare
Signed-off-by: Laura Brehm <[email protected]>
a8844f8
to
f632123
Compare
@@ -49,6 +54,7 @@ func NewLogsCommand(dockerCli command.Cli) *cobra.Command { | |||
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps") | |||
flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs") | |||
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs") | |||
flags.IntVarP(&opts.detachDelay, "delay", "d", 0, "Number of seconds to wait for container restart before exiting") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do what tail
does and put this behind a separate -F
option:
-f The -f option causes tail to not stop when end of file is reached, but rather to wait for additional data to be ap‐
pended to the input. The -f option is ignored if the standard input is a pipe, but not if it is a FIFO.
-F The -F option implies the -f option, but tail will also check to see if the file being followed has been renamed or
rotated. The file is closed and reopened when tail detects that the filename being read from has a new inode number.
If the file being followed does not (yet) exist or if it is removed, tail will keep looking and will display the file
from the beginning if and when it is created.
The -F option is the same as the -f option if reading from standard input rather than a file.
So basically:
-f
would only work on existing containers and exit when the container ends-F
would never exit, it would always just wait for the container, even if it doesn't exist at the time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, I like that UX.
- What I did
Hacky PR for demonstration/discussion purposes only.
Addresses: #5305
- How I did it
- How to verify it
docker run -d --name bork alpine sh -c "while true; do echo hi; sleep 1; done"
docker logs -f --delay 3 bork
docker restart bork
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)