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 dashes in environment (.env) - unexpected character "-" in variable name near #9570

Closed
PraveenAnaparthi opened this issue Jun 17, 2022 · 7 comments

Comments

@PraveenAnaparthi
Copy link

Windows Server 2019
Docker compose - v2.6.0
Docker - Docker version 20.10.9, build 591094d

I am getting unexpected character "-" in variable name near error if environment variable has dash in the name. It worked fine before the upgrade.

@milas
Copy link
Member

milas commented Jun 22, 2022

Related: compose-spec/compose-go#271 (which adds . as a valid character)

@bassstorm
Copy link

Any chance this ticket could be taken in work? In Spring Framework dashes are widely used, and this change doesn't allow developers to use .env file to quickly override app properties. Changing compose YAML source isn't a good idea, since such changes could unintentionally appear in the repo.

@yoda-jm
Copy link

yoda-jm commented Sep 27, 2022

I have the same kind of error on alpine latest with:

  • docker-compose 1.29.2
  • Docker version 20.10.17, build 100c70180fde3601def79a59cc3e996aa553c9b9

When I include the following code in my docker compose file:

services:
  tftpd:
    build: ./tftpd
    restart: unless-stopped
    #network_mode: "host"
    ports:
      - 69:69/udp
    volumes:
      - ${TFTPD_ROOT}:/var/tftpboot
      - ${TFTPD_MAP_FILE}:/etc/tftpd.mapfile

and the environment variables contains a dash, then the port 69 is not exposed without any warning or error (this was hard to debug).
I was able to solve my problem by quoting the volumes (for example: - "${TFTPD_ROOT}:/var/tftpboot").
Hope this helps.

@yoda-jm
Copy link

yoda-jm commented Sep 27, 2022

Edit to my previous post: removing the dash in the environment path or quoting the volume definition indeed bring back the exposed port while executing docker ps.
However it is still not working for me. The directories have some discrepancies:

  • /mnt/diskless: ext4 mount,
  • /mnt/diskless-synology: nfs3 mount.

@asyarif93
Copy link

any update for this?

afaik, specs for env is IEEE Std 1003.1-2001 - any printable character but = and NUL is valid. so this issue should be treated as bug

@nicksieger
Copy link
Member

Thanks for filing compose-spec/compose-go#310 (linking it here).

@ndeloof
Copy link
Contributor

ndeloof commented May 3, 2023

fixed by compose-spec/compose-go#336

@ndeloof ndeloof closed this as completed May 3, 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

7 participants