Skip to content

🐛 Issue: Container uptime not updated and shows incorrect values after container recreation #6

Description

@LordOverlord

Description

When ctop is running and Docker containers are recreated (for example using docker compose up --force-recreate), newly created containers can show an incorrect uptime value such as 292 years.
Additionally, container uptime does not appear to update over time and remains fixed to the value calculated when ctop was started.


Observed behavior

  • Start ctop
  • Recreate containers while ctop is running
  • New containers appear correctly in the UI
  • The UPTIME column:
    • Shows unrealistic values (e.g. 292 years) for newly recreated containers
    • Does not increment over time and remains static

Expected behavior

  • Container uptime should be recalculated periodically (e.g. every minute)
  • Newly recreated containers should display:
    • 0s, N/A, or a small uptime
    • Never an absurd multi-century value

Root cause (analysis)

  • ctop calculates uptime once, based on the container StartedAt timestamp
  • The value is not refreshed periodically
  • During container recreation, Docker may temporarily report:
    • an empty StartedAt
    • a zero time (0001-01-01T00:00:00Z)
  • Because uptime is not updated or sanitized, this results in:
    • now - zero time → extremely large durations (hundreds of years)

Impact

  • This issue affects display accuracy only
  • Container state, stats, and stability are not affected
  • Most visible during dynamic environments (Docker Compose, stack recreation)

Suggested fix

  • Recalculate container uptime periodically (e.g. every 60 seconds)
  • Validate StartedAt before computing uptime:
    • ignore zero or invalid timestamps
    • fallback to N/A or 0s if invalid

Environment

  • ctop running while containers are recreated
  • Docker + Docker Compose
  • Observed consistently during live stack recreation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UXbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions