I am currently trying to run this command from my docker host:
docker exec container_name /bin/bash -c "touch .env; APP_KEY=$(php artisan key:generate | grep -o '\[.*]' | sed 's/[][]//g');"
Problem is that the expression $(expression) will be evaluated by the host, where php is not in the path, like it should be.
How do I tell docker that it should use container shell to evaluate the expression in the container? Or is there maybe another workaround to accomplish this?
The solution is to use single quotes rather than double quotes:
docker exec container_name /bin/bash -c 'touch .env; APP_KEY=$(php artisan key:generate | grep -o '\[.*]' | sed 's/[][]//g');'
In this case, $ expressions won't be expanded in the host command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With