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

docker compose restricts project name, where the spec does not #9741

Closed
simue opened this issue Aug 11, 2022 · 4 comments · Fixed by compose-spec/compose-spec#314
Closed

Comments

@simue
Copy link

simue commented Aug 11, 2022

Description

As a follow up to #9216: docker compose denies creating projects with project names containing dots or uppercase letters. Looking at the compose spec, an arbitrary string can be provided as project name. There is no obvious restriction on the project name content:
https://github.com/compose-spec/compose-spec/blob/master/spec.md?plain=1#L48-L52
https://github.com/compose-spec/compose-spec/blob/master/schema/compose-spec.json#L14-L17

Steps to reproduce the issue:

  1. create a project with arbitrary name containing dot and/or uppercase letters

Describe the results you received:
"settings_pittsburghFL" is not a valid project name

Describe the results you expected:
Project created successfully

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

Output of docker compose version:

Docker Compose version v2.6.1
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 3
  Running: 1
  Paused: 0
  Stopped: 2
 Images: 7
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  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.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version:
 runc version:
 init version:
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.9.253-tegra
 Operating System: Ubuntu 18.04.6 LTS
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 31.18GiB
 Name: anon
 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

Additional environment details:

@yar-sh
Copy link

yar-sh commented Aug 11, 2022

To add to this issue, doesn't seem like name accepts environment variables. Sample docker-compose.yml file:

version: '3.9'
name: $TEST

x-test: &test
  TEST: $TEST

TEST='hello' docker compose convert produces:

name: test
services: {}
x-test:
  TEST: hello

But one would expect to get:

name: hello
services: {}
x-test:
  TEST: hello

@simue
Copy link
Author

simue commented Aug 12, 2022

This behaviour is also observable with docker compose v2.9.0

@mbland
Copy link

mbland commented Feb 24, 2023

I was bitten by this today, and after a little digging, found out what happened. The change was part of compose-spec/compose-go#261, which resolved #9434:

If I'm interpreting correctly, the issue is that different project names could canonicalize to the same name, leading to a conflict and surprising behavior. The solution was to enforce only canonical names to begin with, that essentially must satisfy regexp.MustCompile("[a-z0-9_-]") without any trailing leading - or _ characters.

This landed in:

cc: @paulschuetz

mbland added a commit to mbland/compose-go that referenced this issue Mar 3, 2023
PR compose-spec#261 changed `docker compose` behavior to require normalized project
names as input, instead of normalizing project names automatically. This
landed in compose-spec/compose-go v1.2.5 and docker/compose v2.5.1.

However, the previous error message gave no indication why a name isn't
valid.  This is surprising for users whose previously working project
names no longer work with newer versions of `docker compose`.

As of compose-spec/compose-spec#314, the spec now contains the text:

> Project name MUST contain only lowercase letters, decimal digits,
> dashes, and underscores, and MUST begin with a lowercase letter or
> decimal digit.

This updated error message provides a concise version of this
requirement based on regular expression character range notation.

See also:

- compose-spec/compose-spec#311
- docker/compose#9741

Signed-off-by: Mike Bland <mbland@acm.org>
mbland added a commit to mbland/compose-go that referenced this issue Mar 3, 2023
PR compose-spec#261 changed `docker compose` behavior to require normalized project
names as input, instead of normalizing project names automatically. This
landed in compose-spec/compose-go v1.2.5 and docker/compose v2.5.1.

However, the previous error message gave no indication why a name isn't
valid.  This is surprising for users whose previously working project
names no longer work with newer versions of `docker compose`.

As of compose-spec/compose-spec#314, the spec now contains the text:

> Project name MUST contain only lowercase letters, decimal digits,
> dashes, and underscores, and MUST begin with a lowercase letter or
> decimal digit.

This updated error message provides a concise version of this
requirement based on regular expression character range notation.

See also:

- compose-spec/compose-spec#311
- docker/compose#9741

Signed-off-by: Mike Bland <mbland@acm.org>
@iMarv
Copy link

iMarv commented Mar 27, 2023

Had the same issue, but was not setting a name manually. It turns out the directory name in which the docker-compose.yml is located seems to become the default project name. Fix for me was to set a project name manually in the compose file, but I guess renaming the directory to something lowercase would work out aswell.

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 a pull request may close this issue.

4 participants