Skip to content

[BUG] docker compose up mysteriously errors strconv.Atoi: parsing "": invalid syntax #10004

Closed
@nicks

Description

@nicks

Description

When I run docker compose up --build, i see this error:

[+] Running 0/0
 ⠋ Container viva-extensionsbackend-1  Creating                                                                                                                                                                           0.0s
 ⠋ Container viva-mockbackend-1        Creating                                                                                                                                                                           0.0s
 ⠋ Container cool_chatelet             Recreate                                                                                                                                                                           0.0s
strconv.Atoi: parsing "": invalid syntax

Steps To Reproduce

I have no idea how i got into this state, but I know what the problem is!

I have a container with these labels:

            "Labels": {
                "com.docker.compose.project": "viva",
                "com.docker.compose.service": "electron",
                "com.docker.compose.version": "2.12.2"
            }

The container does NOT have the label com.docker.compose.container-number

The convergence engine blows up trying to figure out how to deal with this.

Here's the first place it blows up:

n, err := strconv.Atoi(c.Labels[api.ContainerNumberLabel])

If I change that line to ignore the error, here's the second place it blows up:

number, err := strconv.Atoi(replaced.Labels[api.ContainerNumberLabel])

The fix that worked for me locally was to change change getContainers here:

containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{

to filter out containers that are missing this label.

Compose Version

available on request

Docker Environment

available on request

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions