3

Here is a particular operation everyone can try:

docker run --env TEST='xxx' ubuntu:14.04 /bin/echo $TEST

That returns an empty string.

1

2 Answers 2

11

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'
Sign up to request clarification or add additional context in comments.

Comments

5

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.