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:
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.
Description
Opening the Containers page fails with:
The affected host runs Docker Swarm and has many long task container names, for example:
This is a common case in Docker Swarm, because task container names are automatically generated as:
and can easily exceed 50 characters.
Cause
ServerBox currently formats
docker psusing fixed-width columns such as:Then it splits the result with:
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.lengthbefore accessingparts[3]so one malformed row does not break the whole Containers page.