I’d say it’s not an issue with special characters. Even all of the following in an .env
file is quoted, at least when shown with set
:
a=123
b=abc456
c='123'
d='abc456'
e="123"
f="abc456"
docker run --rm -it --env-file .env busybox /bin/sh -c set
HOME='/root'
HOSTNAME='1d3be219cb86'
...
TERM='xterm'
a='123'
b='abc456'
c=''"'"'123'"'"
d=''"'"'abc456'"'"
e='"123"'
f='"abc456"'
However, no additional quoting with echo
:
docker run --rm --env-file .env busybox /bin/sh -c 'echo $b'
abc456
docker run --rm --env-file .env busybox /bin/sh -c 'echo $d'
'abc456'
docker run --rm --env-file .env busybox /bin/sh -c 'echo $f'
"abc456"
(And yes, same for a=docker321*!
and the like, also when using docker run --rm -it --env-file .env busybox
and running the set
and echo
commands on the prompt.)
So, what exactly are you doing?