cancel
Showing results for 
Search instead for 
Did you mean: 
Yeni84
Flight Engineer
Flight Engineer
  • 3,351 Views

on Host: podman exec <container-name> echo $VAR1 shows no output

Jump to solution

Hello.
Related to containers and setting environment variables for them, I podman run -d a UBI image with -e VAR1="lab1" and -e VAR2="lab2". When I podman exec echo $VAR1 (echo $VAR2) from the host, I get no output. If I podman attach to the container and I run inside the container echo $VAR1 and echo VAR2 I get lab1 and lab2, respectively. Photo attached. Would you know why when I podman exec echo $VAR1 from the host, there is no output (that is lab1)?
Other variables like USER, PATH show the right output:
[user1@rhcsa6 ~]$ podman exec 789401760acc echo $USER
user1
[user1@rhcsa6 ~]$ podman exec 789401760acc echo $PATH
/home/user1/.local/bin:/home/user1/bin:/home/user1/.local/bin:/home/user1/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
Thank you.problem descriptionproblem description

0 Kudos
1 Solution

Accepted Solutions
Alexandre
Starfighter Starfighter
Starfighter
  • 3,346 Views

Please, try:

podman exec  789401760acc /bin/bash -c 'echo $VAR1'

View solution in original post

2 Replies
Alexandre
Starfighter Starfighter
Starfighter
  • 3,347 Views

Please, try:

podman exec  789401760acc /bin/bash -c 'echo $VAR1'

Yeni84
Flight Engineer
Flight Engineer
  • 3,343 Views

@Alexandre Hello. Your solution worked. Attached photo. Thank you.03 podman exec cannot echo variable from host, solution podman exec container_name -bin-bash -c single quotes echo $VAR1.JPG

Join the discussion
You must log in to join this conversation.