compose icon indicating copy to clipboard operation
compose copied to clipboard

docker compose dashes in environment (.env) - unexpected character "-" in variable name near

Open PraveenAnaparthi opened this issue 3 years ago • 2 comments

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.

PraveenAnaparthi avatar Jun 17 '22 13:06 PraveenAnaparthi

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

milas avatar Jun 22 '22 18:06 milas

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.

bassstorm avatar Aug 31 '22 17:08 bassstorm

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 avatar Sep 27 '22 20:09 yoda-jm

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.

yoda-jm avatar Sep 27 '22 22:09 yoda-jm

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

asyarif93 avatar Sep 29 '22 05:09 asyarif93

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

nicksieger avatar Sep 29 '22 14:09 nicksieger

fixed by https://github.com/compose-spec/compose-go/pull/336

ndeloof avatar May 03 '23 12:05 ndeloof