Skip to content

repeated calls to "logs" emits empty logs #2

Description

@jochumdev

Migrated from https://gitlab.com/r3j0/incus-compose/-/issues/23

Bug

incus-compose logs (without --follow) returns correct output on the first
call but nothing on subsequent calls for running containers.

Root cause

The Incus server's GET /1.0/instances/{name}/console handler calls liblxc
with WriteToLogFile: true. This advances a write cursor in the LXC ring
buffer — each call only returns bytes written after the previous cursor
position. The first call drains all buffered output; subsequent calls return
nothing until new output arrives.

For stopped containers the server reads from the accumulated
ConsoleBufferLogPath() file, which always contains the full history — so
logs works correctly after stop.

Workaround

Use --follow to stream continuously:

incus-compose logs --follow web-1

What we cannot fix client-side

The cursor is advanced server-side. There is no reset or read-from-start
option in the current GET /console REST API.

Potential upstream fix

A reset_cursor or read_from_start query parameter on GET /console would
let clients always read from the beginning of the ring buffer, matching
docker logs semantics.

Until then, --tail (not yet implemented) could partially help by
reading from the log file for stopped instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions