diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index d96647e51cc0..deb726526d01 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -209,9 +209,6 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption containerCouldBeLogging = true case events.Exited: containerCouldBeLogging = false - if doTail { - doTailFunc() - } } continue } diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index db50c8f8c283..823b8180f57e 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -30,6 +30,23 @@ load helpers run_podman rm $cid } +@test "podman logs - tail test" { + rand_string=$(random_string 40) + + run_podman run -d $IMAGE sh -c "echo test1; echo test2" + cid="$output" + + run_podman logs --tail 1 $cid + is "$output" "test2" "logs should only show last line" + + run_podman restart $cid + + run_podman logs --tail 1 $cid + is "$output" "test2" "logs should only show last line" + + run_podman rm $cid +} + function _additional_events_backend() { local driver=$1 # Since PR#10431, 'logs -f' with journald driver is only supported with journald events backend.