Skip to content

Reading a Compose file results in undefined Labels #9808

@paroque28

Description

@paroque28

Description

Steps to reproduce the issue:

  1. git clone https://github.com/paroque28/compose-test
  2. cd compose-test
  3. pkg/compose-test/main.go

Describe the results you received:
If I comment the following lines of code:

if project.Services[i].CustomLabels == nil {
			project.Services[i].CustomLabels = map[string]string{
				api.ProjectLabel: project.Name,
			}
		}

I get the following error:

panic: assignment to entry in nil map

goroutine 1 [running]:
main.readComposeFile({0x1274cf9, 0x12})
        /home/pablo/compose-test/pkg/compose-test/main.go:57 +0x49a
main.StartProject({0x1274cf9, 0x12})
        /home/pablo/compose-test/pkg/compose-test/main.go:78 +0x1a5
main.main()
        /home/pablo/compose-test/pkg/compose-test/main.go:102 +0x29
exit status 2

Describe the results you expected:
Not an error, an initialized custom labels string map

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker compose version:
github.com/docker/compose/v2 v2.10.2

(paste your output here)

Output of docker info:

(paste your output here)

Additional environment details:

Related to:

#9579

And:
docker/roadmap#387

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions