Skip to content

Docker container page fails with ParsePs RangeError for long Swarm container names #1226

Description

@mingzhao2019

Description

Opening the Containers page fails with:

ContainerErr<ParsePs>: RangeError (length):
Invalid value: Not in inclusive range 0..2: 3

The affected host runs Docker Swarm and has many long task container names, for example:

apps-all-stack_komari-agent.zdngp1z1t23llz9l30s86tq3g.fjmkg9amn0u76tbln96mmzlq2

This is a common case in Docker Swarm, because task container names are automatically generated as:

stack_service.nodeid.taskid

and can easily exceed 50 characters.

Cause

ServerBox currently formats docker ps using fixed-width columns such as:

%-15.15s %-30.30s %-50.50s %-50.50s

Then it splits the result with:

RegExp(r'\s{2,}')

If the container name fills the full 50-character width, only one space remains before the image column, so the parser gets only 3 parts and parts[3] throws the RangeError.

Suggested fix

Please avoid parsing fixed-width, whitespace-aligned output.

For example, use tabs:

docker ps -a --format '{{.ID}}\t{{.State}}\t{{.Names}}\t{{.Image}}'

and split by \t.

Or use JSON:

docker ps -a --format '{{json .}}'

Also, please check parts.length before accessing parts[3] so one malformed row does not break the whole Containers page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions