docker / docker/docker-py

Flooring `since` and `until` datetime arguments down to second resolution in `container.logs`.

Open
#3,342 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

I was surprised to figure out that when you pass since and until arguments to container.logs() as datetimes they internally are floored down to the closest second with utils.datetime_to_timestamp(...).

Millisecond part of datetime is discarded.

That leads to unwanted extra logs in the output from the past before since and absent valid logs before until.

For example:

since = datetime(2025, 6, 1, hour=12, minute=0, second=0, microsecond=500_000)
logs = container.logs(since=since)
# logs would have EXTRA records in half a second from 12:00:00.000 to 12:00:00.500

until = datetime(2025, 6, 1, hour=12, minute=0, second=0, microsecond=500_000)
logs = container.logs(until=until)
# logs would NOT have records in half a second from 12:00:00.000 to 12:00:00.500

Is it by design and I need to manually convert datetime to float in such usecase?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with container.logs and utils.datetime_to_timestamp, then check how the Docker Engine API represents the since and until values. The issue does not name a file or test, so first confirm whether sub-second precision is intended; done requires a maintainer decision and behavior checks for the reported datetime boundaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.