use .env file with docker

Viewed 256

I started to use Docker and 'Dockerized' my Next.js project, how Docker acts with an .env file? I have an .env file that contains my DB login information/URI, now since Docker copying all the content of the project directory, I guess yarn reading the .env file, but is it really works like that? and is it secured? (since the docker image contains the .env file(?) I saw the only way to send ENV values is by writing them inside the Dockerfile file as ENV name value but i think its not really secured that way either(?) Thanks!

1 Answers

from what i have read, you could just add Dockerfile to list of ignored files in .dockerignore so it wont be copied to docker image. correct me if im wrong

Related