1

I'm trying to use the target host's env variable to parametrize my container when launching it with the remote API, but none of these worked ...

   "Env": [
        "ENV_VAR=`$TEST`",
        "ENV_VAR2=$TEST"
   ],

Does anyone have an idea how to achieve this ?

pedro
  • 11
  • 2

1 Answers1

0

I'm feeding a json while POSTing to : /containers/create?name=myName -d payload.json ("Env" being in the root of the payload)

If $TEST is an environment variable from the host, the payload.json needs to include its value, not $TEST, as the POST will not change/interpret $TEST (but pass it literally).

If, instead of using a payload.json file, you used a command with the json directly in it, you could wrap the json part between double quotes: then $TEST would be interpreted by the shell.
See "How to include environment variable in bash line CURL?"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The environment variable is meant to be taken from the target host, not the client using the remote API – pedro Feb 05 '16 at 12:05
  • @pedro the remote API itself is not like a shell: it won't interpret anything. – VonC Feb 05 '16 at 12:15
  • Yeah i understand that, but there could have been a way for the remote docker to start the container using its host env ..., thanks anyway for you time. – pedro Feb 05 '16 at 13:29