I\'m new to Docker, and it\'s unclear how to access an external database from a container. Is the best way to hard-code in the connection string?
# Dockerfil
docker run --rm -it --env-file <(bash -c 'env | grep
Is a way to grep the data stored within a .env
and pass them to Docker, without anything being stored unsecurely (so you can't just look at docker history
and grab keys.
Say you have a load of AWS stuff in your .env
like so:
AWS_ACCESS_KEY: xxxxxxx
AWS_SECRET: xxxxxx
AWS_REGION: xxxxxx
running docker with ```docker run --rm -it --env-file <(bash -c 'env | grep AWS_') will grab it all and pass it securely to be accessible from within the container.