docker compose dashes in environment (.env) - unexpected character "-" in variable name near
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.
Related: compose-spec/compose-go#271 (which adds . as a valid character)
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.
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.
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.
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
Thanks for filing compose-spec/compose-go#310 (linking it here).
fixed by https://github.com/compose-spec/compose-go/pull/336