I think I'm missing something, but couldn't grok t...
# general
b
I think I'm missing something, but couldn't grok this from the docs. How can I get env vars propagated to
./pants run <docker_img>
? I've tried `--docker-env-vars="MYVAR"`:
MYVAR=1 ./pants --docker-env-vars="MYVAR" run <docker>
, but the
pex_binary
which is run is no dice. I suspect maybe
docker.run_args
?
Ah
-e
on
docker.run_args
should do it, but I get
"docker run" requires at least 1 argument.
🤔 I'm using
--docker-run-args="-e"
so it should be _append_ing a value
Oh you need a
-e
and then the name 🤦‍♂️
@happy-kitchen-89482 here's another case of default
run_args
on a
docker_image
target would be nice
👀 1
I'll open a ticket
c
Can you help me understand why setting --docker-env-vars="[\"MYARG\"]" does not propagate the MYARG, but docker-run-args="-e MYARG" does? I was very confused why the env variables didn't show up until I saw this post.
b
IIUC, The first one propagates the environment variable to the docker-related processes (so Pants is providing the environment variable). The second one is telling docker itself to grab the env var from environment. Put another way, the first makes sure the variable is in the sandbox, the second is telling docker to use it
c
Copy code
Put another way, the first makes sure the variable is in the sandbox, the second is telling docker to use it
But the variable does not have to be in the sandbox, for docker to pick it up when doing
pants run
on a docker image target. I guess it's not obvious to me why a pants run on a docker image (which leads to a
docker run
command, does not count as an invocation. According to the docs
Environment variables to set for docker invocations.
I have what I need now, but I would humbly suggest that maybe the documentation could have been clarified.
b
Admittedly this is a year old thread so my remembering of the details is likely weathered 😅
c
Totally understandable, but you gave me all the help I needed. Thanks a lot:)
b
Well glad for that. 🙂 Pass it on!