On 6/27/21 10:33, Erik Sjölund wrote:
James,
It looks like your $VAR expands too early (in your current bash shell
and not in the bash shell inside the container).
I tested it by running
$ podman run -d --name testctr2 docker.io/library/fedora sleep 3600
and then these commands
$ podman exec -e VAR=bob testctr bash -c "env" | grep bob
VAR=bob
$ podman exec -e VAR=bob testctr bash -c "echo $VAR" | grep bob
$ podman exec -e VAR=bob testctr bash -c "echo \$VAR" | grep bob
bob
$
Correct this is why I was using printenv VAR, which eliminates the $VAR
from being expanded in the host shell,versus in the container shell.
Erik
On Sun, Jun 27, 2021 at 1:32 PM Daniel Walsh <dwalsh(a)redhat.com> wrote:
> On 6/27/21 06:41, James Miller wrote:
>
> Hi,
>
> I have a problem with an environment variable that I am passing into an exec session.
The command has worked in the past but recently, I am unable to pass an environment
variable that a called executable can see properly. If I run, podman exec -e
VAR='bob' -it some_cont bash -c "env", the environment is printed out
and includes the environment variable VAR='bob'.
>
> But I can not run podman exec .... bash -c "echo $VAR" successfully, nor in
my current situation am I able to run podman exec -e PASSWORD="$var_I_just_read"
.... bash -c "mysql -uroot -p${PASSWORD}... ". Because the env variable
PASSWORD is not present, the mysql command asks for a password. This was certainly
working ok previously, but doesn't seem to function now.
> I have tried a bunch of different permutations, including running the command with
real variables instead of environment variables, and it works ok. Also, I am sure that I
used to be able to run 'podman exec -e SOMEVAR='Bob' -it cont_name bash -c
"echo $SOMEVAR" and get Bob output.
>
> What am I doing wrong?
>
> MTIA, James
> --
> James Stewart Miller Bsc(hons) Psych.
>
> _______________________________________________
> Podman mailing list -- podman(a)lists.podman.io
> To unsubscribe send an email to podman-leave(a)lists.podman.io
>
> This looks like it is working correctly
>
>
> var=hello; podman exec -e PASSWORD="$var"
e8e0b9aa6ae06dd29079f9bdc7d032431a0d741ed6c3f4c42432ed3e9a759a49 printenv PASSWORD
> hello
>
>
> _______________________________________________
> Podman mailing list -- podman(a)lists.podman.io
> To unsubscribe send an email to podman-leave(a)lists.podman.io
_______________________________________________
Podman mailing list -- podman(a)lists.podman.io
To unsubscribe send an email to podman-leave(a)lists.podman.io