Konstantin Komissarov
Konstantin Komissarov

Reputation: 365

Why variable in docker is empty?

I try to pass env variable into my docker container and then print it

docker exec -e VAR1=1 backend echo $VAR1

But in this case I get an empty output. Why variable is not set into container?

Upvotes: 0

Views: 423

Answers (1)

Praneeth Kumar
Praneeth Kumar

Reputation: 234

from official docker documentation. COMMAND should be executable, a chained or a quoted command will not work. Example: docker exec -ti my_container "echo a && echo b" will not work, but docker exec -ti my_container sh -c "echo a && echo b" will. https://docs.docker.com/engine/reference/commandline/exec/

Upvotes: 1

Related Questions