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

[BUG] running docker-compose for latest version returns unexpected character v2.14.2 #10126

Closed
ayzeenm opened this issue Dec 28, 2022 · 5 comments

Comments

@ayzeenm
Copy link

ayzeenm commented Dec 28, 2022

Description

running docker-compose commands returns the following error for all docker-compose varaitions:
unexpected character "-" in variable name near "docker-compose up -d --build"

Steps To Reproduce

linux
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Compose Version

docker compose version
docker: 'compose' is not a docker command.

 docker-compose version
Docker Compose version v2.14.2

Docker Environment

Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 11
 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: 1e7bb5b773162b57333d57f612fd72e3f8612d94
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.135-122.509.amzn2.x86_64
 Operating System: Amazon Linux 2
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.829GiB
 Name: ip-172-31-32-234.eu-central-1.compute.internal
 ID: 3JDY:TV7W:IZTH:DJCU:YMEE:NWC7:B5AC:MDSY:U4XL:2UXK:ZZ2M:KEII
 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

Anything else?

No response

@ayzeenm ayzeenm changed the title [BUG] <title> running docker-compose for latest version returns unexpected character v2.14.2 [BUG] running docker-compose for latest version returns unexpected character v2.14.2 Dec 28, 2022
@ayzeenm
Copy link
Author

ayzeenm commented Dec 29, 2022

Fixed by using v1.29.2. latest version doesn't work

@thaJeztah
Copy link
Member

Error looks to come from the .env parser; https://github.com/compose-spec/compose-go/blob/7d49c99fcfd2f99332d95e3b69c0c8d07fa13422/dotenv/parser.go#L119

  • Do you have a .env file present?
  • What does command -v docker-compose show? (Is it possible it's an alias or script?)

I tried reproducing this issue on an Ubuntu machine, but didn't get the same issue (without a .env file);

docker compose up -d --build
[+] Building 0.8s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                            0.1s
 => => transferring dockerfile: 81B                                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/nginx:alpine                                                                                                                                                 0.0s
 => [1/2] FROM docker.io/library/nginx:alpine                                                                                                                                                                   0.1s
 => [2/2] RUN echo hello > out.txt                                                                                                                                                                              0.6s
 => exporting to image                                                                                                                                                                                          0.1s
 => => exporting layers                                                                                                                                                                                         0.1s
 => => writing image sha256:7fe49432325a15622b63ebb011465102f3ed96b9c90f6cffe041bd72709bdc7f                                                                                                                    0.0s
 => => naming to docker.io/library/foo-web                                                                                                                                                                      0.0s
[+] Running 2/2
 ⠿ Network foo_default  Created                                                                                                                                                                                 0.1s
 ⠿ Container foo-web-1  Started                                                                                                                                                                                 0.7s


docker-compose up -d --build
[+] Building 0.1s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                            0.0s
 => => transferring dockerfile: 81B                                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                                                                                 0.0s
 => [internal] load metadata for docker.io/library/nginx:alpine                                                                                                                                                 0.0s
 => [1/2] FROM docker.io/library/nginx:alpine                                                                                                                                                                   0.0s
 => CACHED [2/2] RUN echo hello > out.txt                                                                                                                                                                       0.0s
 => exporting to image                                                                                                                                                                                          0.0s
 => => exporting layers                                                                                                                                                                                         0.0s
 => => writing image sha256:6255e9b45135f2d8dbae745e3ec6ee935d20c9347dafcb54361d6da1347e691c                                                                                                                    0.0s
 => => naming to docker.io/library/foo-web                                                                                                                                                                      0.0s
[+] Running 1/1
 ⠿ Container foo-web-1  Started                                                                                                                                                                                 0.7s

@ayzeenm
Copy link
Author

ayzeenm commented Dec 30, 2022

So I run docker-compose without any additional arguments and get this error:
unexpected character "-" in variable name near "docker-compose up -d --build"

@ndeloof
Copy link
Contributor

ndeloof commented Jan 6, 2023

This is probably fixed by compose-spec/compose-go#336
Anyway, we should offer a better error to the user, with some details on the file we failed to parse, so keeping this issue open for this purpose

@ayzeenm
Copy link
Author

ayzeenm commented Jan 7, 2023

Amazing! thank you @ndeloof , it actually got fixed

@ndeloof ndeloof closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants