Reputation: 7686
Here is a particular operation everyone can try:
docker run --env TEST='xxx' ubuntu:14.04 /bin/echo $TEST
That returns an empty string.
Upvotes: 3
Views: 9777
Reputation: 6347
The reason why echoing isn't working is that the $TEST
environment variable is substituted on your host side. To postpone the substitution to container side, wrap the echo command with single quotes:
docker run --env TEST='xxx' ubuntu:14.04 sh -c 'echo $TEST'
Upvotes: 11
Reputation: 11543
You're substituting TEST in your bash instead of your container. Try this command to make sure your variable is passed correctly:
docker run --env TEST='xxx' ubuntu:14.04 /usr/bin/env
Upvotes: 5