-
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
docker container logs --follow
will quit if the container is restarted
#5305
Comments
Hiya, thanks for the report.
This isn't quite so – when a container dies, the logger attached to it streaming messages over from the daemon is closed. This causes the CLI to exit, since running If the CLI was aware that the reason the stream was ended was because the container was being restarted, it could hang (instead of exiting) and attempt to restart the stream. However, this isn't currently the case. I guess the CLI could start streaming events from the daemon while streaming logs, and decide based on that. 2024-07-30T09:27:45.637609939Z container stop 81554c2ed5536f632dbd3b0942574ac528594b5e7c941f3d82fcaeba338131f4 (image=alpine, name=quizzical_colden)
2024-07-30T09:27:45.639755151Z container die 81554c2ed5536f632dbd3b0942574ac528594b5e7c941f3d82fcaeba338131f4 (execDuration=41, exitCode=137, image=alpine, name=quizzical_colden)
2024-07-30T09:27:45.655764850Z network connect e96cf3e6b07b3bd6b8b0e93aca78ff46fac383b1023c72f7efbe3ae2ff7c828b (container=81554c2ed5536f632dbd3b0942574ac528594b5e7c941f3d82fcaeba338131f4, name=bridge, type=bridge)
2024-07-30T09:27:45.791383745Z container start 81554c2ed5536f632dbd3b0942574ac528594b5e7c941f3d82fcaeba338131f4 (image=alpine, name=quizzical_colden)
2024-07-30T09:27:45.791437579Z container restart 81554c2ed5536f632dbd3b0942574ac528594b5e7c941f3d82fcaeba338131f4 (image=alpine, name=quizzical_colden) Which means that we could do something like hold for a few seconds after a container stops and wait for a restart/attempt to restart the log stream in that case, but there's a few questions in this case, and this requires some discussion. |
Laura thanks for quick reply. I am thinking about this from the contract perspective: what is The other reason for suggested improvement is the complexity associated with the use of the CLI. The client (the user of the CLI) does not necessarily know why the |
Hiya! FWIW, we were discussing adding a
Re: the contract perspective for We can however introduce a new flag for the desired (more intuitive) behavior. The fact that this also mimics the
is a plus for me since it's UX that users might already be aware of. Do you have other suggestions? I also considered adding a message to the output of |
Thanks Laura. I agree that adding a "message" to the output of Regarding the new flag, the way I use the If you are unwilling to change the default behavior of the command , I understand your point, although FWIIW your competition works like I suggested originally (the |
Thanks for the feedback! FWIW, (from my highly biased perspective, so take that for what it's worth), for however many people might prefer our "competition"'s behavior, I'm sure there are lots that would prefer to have Regardless, I see your points about:
This seems sane to me (and was the approach I was initially considering for #5307). @thaJeztah @vvoland thoughts on the UX here? We could do a |
Description
The command
docker container logs --follow
with quit if the container is restarted. Re-issuing the command will get the logs from before restart as well as after restart, but it should not be necessary.Reproduce
docker run -d -p:6556:80 nginx
docker container logs --follow <nginx container id>
docker container restart <nginx container id>
Expected behavior
The
container logs --follow
command should just continue streaming logs. The container is just restarted; it has the same container ID, there is no need to stop execution of thelogs
command.docker version
docker info
Diagnostics ID
57094215-4B96-4228-8AC0-63705A3A1BAD/20240729165901
Additional Info
No response
The text was updated successfully, but these errors were encountered: