Skip to content

fix: align ContainerInfo fields with inspect format template#10

Closed
juandiii wants to merge 0 commit into
floci-io:mainfrom
juandiii:main
Closed

fix: align ContainerInfo fields with inspect format template#10
juandiii wants to merge 0 commit into
floci-io:mainfrom
juandiii:main

Conversation

@juandiii

Copy link
Copy Markdown

Problem

floci start treated a running container as stopped and then failed trying to remove it:

cannot remove container ... as it is running - running or paused containers cannot be removed without force

The root cause was a field-mapping bug in inspectContainer. The docker inspect format template emitted a duplicate {{.State.Status}}, producing 6 fields while the data only had 5. Every field after the image was off by one, so status ended up mapped to the ports slot. As a result state() returned the wrong value, never matched "running", and the start flow attempted to docker rm a live container.

Separately, the command used docker inspect (no subcommand), which falls back to images when no container matches. With an image named floci present, the template rendered against the image and failed at {{.Name}}:

template parsing error: executing "" at <.Name>: map has no entry for key "Name"

Fix

Change Detail
Use docker container inspect Prevents fallback to images; a missing container yields No such container instead of rendering against an image
Remove duplicate {{.State.Status}} Template now emits 5 fields: id, name, image, status, ports
Align ContainerInfo constructor Reads parts[0..4]; statusparts[3], portsparts[4]
Map "no such container" to Optional.empty() A missing container is absence, not an error

Verification

  • All unit tests pass (mvn test).
  • inspectContainer returns the correct status for running, stopped, and missing containers.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant