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] docker compose when parentheses are present in entrypoint or command strings #9965

Closed
mRokita opened this issue Oct 30, 2022 · 4 comments

Comments

@mRokita
Copy link

mRokita commented Oct 30, 2022

Description

The bug effectively disables me from using traefik's providers.docker.constraints flag, which requires presence of parentheses in the command/entrypoint string:

command: "--providers.docker --providers.docker.constraints=Label(pycon.traefik, true)"

Everytime I try running docker compose up, the following decoding error is printed:

1 error(s) decoding:

* error decoding 'Command': invalid command line string

When I remove parentheses from the command it starts up, but these braces are needed there for Traefik to understand the constraint.

Using docker compose --compatibility up doesn't solve the issue.

Docker Compose v1 has no issues with decoding the same compose file.

Steps To Reproduce

  1. Create a docker-compose.yml file with the following contents:
version: "3"

services:
  traefik:
    image: traefik:v2.9.4
    command: "--providers.docker --providers.docker.constraints=Label(pycon.traefik, true)"
  1. Run docker compose up
  2. The following error appears
1 error(s) decoding:

* error decoding 'Command': invalid command line string
  1. Removing braces ( and ) removes the error, but then Traefik does not understand the syntax.

Compose Version

Docker Compose version v2.12.2

Docker Environment

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

Server:
 Containers: 21
  Running: 1
  Paused: 0
  Stopped: 20
 Images: 203
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 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: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.19.16-200.fc36.x86_64
 Operating System: Fedora Linux 36 (Workstation Edition)
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 13.38GiB
 Name: xxx
 ID: P76X:OF5F:UHWN:5K2W:C4W6:CN5Q:7DWI:PJZ7:ECNO:UCW4:PBCJ:AG7G
 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

@mRokita mRokita changed the title [BUG] docker compose crashes when braces are present in entrypoint or commandline strings [BUG] docker compose crashes when braces are present in entrypoint or command strings Oct 30, 2022
@mRokita mRokita changed the title [BUG] docker compose crashes when braces are present in entrypoint or command strings [BUG] docker compose parentheses when braces are present in entrypoint or command strings Oct 30, 2022
@mRokita mRokita changed the title [BUG] docker compose parentheses when braces are present in entrypoint or command strings [BUG] docker compose when parentheses are present in entrypoint or command strings Oct 30, 2022
@mRokita
Copy link
Author

mRokita commented Oct 30, 2022

I'm sorry - this is probably a duplicate of #8512, which has been closed because of inactivity :/
I posted a workaround there: #8512 (comment)

@ndeloof
Copy link
Contributor

ndeloof commented Dec 23, 2022

Until we get such corner case better supported by shellwords library (see mattn/go-shellwords#54) you can use quotes:

services:
  traefik:
    image: traefik:v2.9.4
    command: "--providers.docker --providers.docker.constraints='Label(pycon.traefik, true)'"

@antichris
Copy link

antichris commented Jan 7, 2023

Escaping with backslashes also works.

services:
  traefik:
    image: traefik:v2.9.4
    command: --providers.docker --providers.docker.constraints=Label\(pycon.traefik,\ true\)

FWIW, it seems that this behavior is compliant with the POSIX.1-2017 standard specification, where the parentheses are defined as control operators that require quoting.

@ndeloof
Copy link
Contributor

ndeloof commented May 11, 2023

Considering control operators are well defined in POSIX (thanks @antichris for the link) and quoting is both recommended and a simple workaround, I'm closing this issue as "not planned"
We still can expect mattn/go-shellwords#54 to be fixed at some point and offer more flexibility to compose users.

@ndeloof ndeloof closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 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