Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

podman exec --env-file seemingly not working

Tags:

podman

trying to run the following command:

podman exec -it  --env-file=./env/local.env bbss superset fab create-admin \
    --username ${BBSS_ADMIN_USERNAME} \
    --firstname ${BBSS_ADMIN_FIRSTNAME} \
    --lastname ${BBSS_ADMIN_LASTNAME} \
    --email ${BBSS_ADMIN_EMAIL} \
    --password ${BBSS_ADMIN_PASSWORD}

my env file looks like this:

BBSS_ADMIN_USERNAME=admin
BBSS_ADMIN_FIRSTNAME=Adam
BBSS_ADMIN_LASTNAME=Adams
[email protected]
BBSS_ADMIN_PASSWORD=xxx

however, I'll get errors indicating that my env vars are blank:

Error: Option '--password' requires an argument.

I have used --env-file with podman run and the same env file and it works fine

Any indication of what I'm doing wrong here?

like image 465
Pompey Magnus Avatar asked Dec 29 '25 06:12

Pompey Magnus


1 Answers

Remember that your local shell interprets variable references before executing a command. If you run...

podman exec mycontainer somecomand $SOMEVARIABLE

Then the value of $SOMEVARIABLE comes from your local shell, not from the shell inside the container. To make your command work, you would need to do something like this:

podman exec -it  --env-file=./env/local.env bbss sh -c '
superset fab create-admin \
    --username ${BBSS_ADMIN_USERNAME} \
    --firstname ${BBSS_ADMIN_FIRSTNAME} \
    --lastname ${BBSS_ADMIN_LASTNAME} \
    --email ${BBSS_ADMIN_EMAIL} \
    --password ${BBSS_ADMIN_PASSWORD}
'

Here, we're using single quotes to inhibit variable expansion by the local shell, and passing the entire command to a shell in the container.

like image 170
larsks Avatar answered Jan 01 '26 10:01

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!