Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when numbers as name for volumes in docker compose v2 #9652

Closed
reaseno opened this issue Jul 14, 2022 · 4 comments · Fixed by compose-spec/compose-go#402
Closed

Error when numbers as name for volumes in docker compose v2 #9652

reaseno opened this issue Jul 14, 2022 · 4 comments · Fixed by compose-spec/compose-go#402
Labels

Comments

@reaseno
Copy link

reaseno commented Jul 14, 2022

Description

I only use numbers as identifiers for volumes. With docker compose v2 I get an error of Go when I run docker compose up.
This worked in docker-compose v1.

Steps to reproduce the issue:

  1. Use volumes named by numbers.
  '0':
    [...]
    volumes:
      - 0:/var/www/

[...]

volumes:
  conf:
  vhost:
  html:
  dhparam:
  certs:
  '0':
  1. docker compose up

Describe the results you received:

panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/compose-spec/compose-go/loader.isFilePath({0xc0004b47d0, 0x1})
        github.com/compose-spec/[email protected]/loader/volume.go:179 +0xc5
github.com/compose-spec/compose-go/loader.populateType(0xc00063baf0)
        github.com/compose-spec/[email protected]/loader/volume.go:148 +0x2d
github.com/compose-spec/compose-go/loader.ParseVolume({0xc0002d5f00, 0x1b})
        github.com/compose-spec/[email protected]/loader/volume.go:59 +0x450
github.com/compose-spec/compose-go/loader.glob..func9({0x108dbe0?, 0xc0004868e0?})
        github.com/compose-spec/[email protected]/loader/loader.go:977 +0x1c5
github.com/compose-spec/compose-go/loader.createTransformHook.func1({0x108dbe0?, 0xc0004868e0?}, {0x14988e0?, 0x123cf60?}, {0x108dbe0, 0xc0004868e0})
        github.com/compose-spec/[email protected]/loader/loader.go:406 +0x5d
github.com/mitchellh/mapstructure.DecodeHookExec({0x111d540?, 0xc0000ca400?}, {0x108dbe0?, 0xc0004868e0?, 0x10e1b40?}, {0x123cf60?, 0xc00047a4d0?, 0x1112060?})
        github.com/mitchellh/[email protected]/decode_hooks.go:47 +0x190
github.com/mitchellh/mapstructure.ComposeDecodeHookFunc.func1({0x108dbe0?, 0xc0004868e0?, 0x0?}, {0x123cf60?, 0xc00047a4d0?, 0xa?})
        github.com/mitchellh/[email protected]/decode_hooks.go:69 +0x10c
github.com/mitchellh/mapstructure.DecodeHookExec({0x10e1b40?, 0xc00025b340?}, {0x108dbe0?, 0xc0004868e0?, 0xc0004b47b0?}, {0x123cf60?, 0xc00047a4d0?, 0x18?})
        github.com/mitchellh/[email protected]/decode_hooks.go:51 +0xd3
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc00061b310, {0xc0004b47b0, 0xa}, {0x108dbe0?, 0xc0004868e0?}, {0x123cf60?, 0xc00047a4d0?, 0x147b6e8?})
        github.com/mitchellh/[email protected]/mapstructure.go:459 +0x179
github.com/mitchellh/mapstructure.(*Decoder).decodeSlice(0xc00061b310, {0x1042116, 0x7}, {0x1073160, 0xc000139cb0?}, {0x106d3a0?, 0xc0003af398?, 0xc000380670?})
        github.com/mitchellh/[email protected]/mapstructure.go:1139 +0x885
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc00061b310, {0x1042116, 0x7}, {0x1073160?, 0xc000139cb0?}, {0x106d3a0?, 0xc0003af398?, 0x17?})
        github.com/mitchellh/[email protected]/mapstructure.go:488 +0x3f7
github.com/mitchellh/mapstructure.(*Decoder).decodeStructFromMap(0xc00061b310, {0x0, 0x0}, {0x10ee6e0?, 0xc0004d6ea0?, 0x1?}, {0x1294cc0?, 0xc0003aef00?, 0xc00025b320?})
        github.com/mitchellh/[email protected]/mapstructure.go:1411 +0x1b50
github.com/mitchellh/mapstructure.(*Decoder).decodeStruct(0x10e1b40?, {0x0, 0x0}, {0x10ee6e0?, 0xc0004d6ea0?}, {0x1294cc0?, 0xc0003aef00?, 0x203000?})
        github.com/mitchellh/[email protected]/mapstructure.go:1235 +0x4ab
github.com/mitchellh/mapstructure.(*Decoder).decode(0xc00061b310, {0x0, 0x0}, {0x10ee6e0?, 0xc0004d6ea0?}, {0x1294cc0?, 0xc0003aef00?, 0x50?})
        github.com/mitchellh/[email protected]/mapstructure.go:482 +0x3cf
github.com/mitchellh/mapstructure.(*Decoder).Decode(0xc00061b310, {0x10ee6e0, 0xc0004d6ea0})
        github.com/mitchellh/[email protected]/mapstructure.go:417 +0xd8
github.com/compose-spec/compose-go/loader.Transform({0x10ee6e0, 0xc0004d6ea0}, {0x1124d40?, 0xc0003aef00}, {0x0, 0x0, 0x0})
        github.com/compose-spec/[email protected]/loader/loader.go:357 +0x19d
github.com/compose-spec/compose-go/loader.LoadService({0xc000380588, 0x5}, 0xc000380588?, {0xc000610440, 0x1e}, 0x18?, 0x1, 0x0)
        github.com/compose-spec/[email protected]/loader/loader.go:560 +0xae
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc000610440, 0x32}, {0xc000380588, 0x5}, 0x0?, {0xc000610440, 0x1e}, 0xc0001a6720?, 0xc00060ca50, 0xc00063d2f8)
        github.com/compose-spec/[email protected]/loader/loader.go:493 +0x128
github.com/compose-spec/compose-go/loader.LoadServices({0xc000610440, 0x32}, 0x129d046?, {0xc000610440, 0x1e}, 0x4?, 0x82e424b3d616b8c3?)
        github.com/compose-spec/[email protected]/loader/loader.go:472 +0x1d1
github.com/compose-spec/compose-go/loader.loadSections({0xc000610440, 0x32}, 0xc0003fc200?, {{0x0, 0x0}, {0xc000610440, 0x1e}, {0xc0006124e0, 0x2, 0x2}, ...}, ...)
        github.com/compose-spec/[email protected]/loader/loader.go:296 +0x2cb
github.com/compose-spec/compose-go/loader.Load({{0x0, 0x0}, {0xc000610440, 0x1e}, {0xc0006124e0, 0x2, 0x2}, 0xc00060c7e0}, {0xc00061c408, 0x3, ...})
        github.com/compose-spec/[email protected]/loader/loader.go:184 +0x912
github.com/compose-spec/compose-go/cli.ProjectFromOptions(0xc000140230)
        github.com/compose-spec/[email protected]/cli/options.go:359 +0x2d7
github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProject(0xc0005ad780, {0xc000164520, 0x1, 0x2}, {0xc0007bfa60?, 0x18?, 0x7fbaa7dcc108?})
        github.com/docker/compose/v2/cmd/compose/compose.go:162 +0x7d
github.com/docker/compose/v2/cmd/compose.(*projectOptions).WithServices.func1({0x148dc88, 0xc00031a180}, {0xc000164520, 0x1, 0x2})
        github.com/docker/compose/v2/cmd/compose/compose.go:119 +0x98
github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x148dc88?, 0xc00031a180?}, 0x2?, {0xc000164520?, 0x1?, 0xc0007bfb08?})
        github.com/docker/compose/v2/cmd/compose/compose.go:89 +0x36
github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc000406000, {0xc000164520, 0x1, 0x2})
        github.com/docker/compose/v2/cmd/compose/compose.go:68 +0x21c
github.com/spf13/cobra.(*Command).execute(0xc000406000, {0xc00012cc60, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc00003c500)
        github.com/spf13/[email protected]/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:902
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0x40d807?, 0xc00041fb80, {{0x12980ac, 0x5}, {0x129fa99, 0xb}, {0x147b32c, 0x6}, {0x0, 0x0}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:51 +0x130
github.com/docker/cli/cli-plugins/plugin.Run(0x132ec10, {{0x12980ac, 0x5}, {0x129fa99, 0xb}, {0x147b32c, 0x6}, {0x0, 0x0}, {0x0, ...}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:64 +0xee
main.pluginMain()
        github.com/docker/compose/v2/cmd/main.go:36 +0xdf
main.main()
        github.com/docker/compose/v2/cmd/main.go:69 +0x1aa

Output of docker compose version:

Docker Compose version v2.6.1

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., v2.6.1)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 28
  Running: 28
  Paused: 0
  Stopped: 0
 Images: 605
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-122-generic
 Operating System: Ubuntu 20.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 22.93GiB
 ID: 2JFQ:MANY:Z4Z7:NLXI:BCN4:X6ZF:C2BL:FJ2M:JZHH:JMBI:LYCM:T44Q
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
@ulyssessouza
Copy link
Collaborator

Hello.

Could you please provide a minimal testcase for us to be able to reproduce?

@reaseno
Copy link
Author

reaseno commented Jul 29, 2022

Hi, what else is needed besides the steps for reproduction in which I had given a minimal example? As far as I can see, it is irrelevant what the service itself does. It is only about the volume names. So it would be enough to take an existing project with volume and adjust the volume name there according to my instructions.

@reaseno
Copy link
Author

reaseno commented Oct 9, 2022

Could the behavior already be reproduced?

@ndeloof
Copy link
Contributor

ndeloof commented May 12, 2023

sorry to be late on this.
issue is indeed easy to reproduce, that's uncommon to use plain numbers for volume references, but this is perfectly valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants