Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define ENV vars in Dockerfile #5

Open
dantownsend opened this issue Nov 19, 2024 · 5 comments
Open

Define ENV vars in Dockerfile #5

dantownsend opened this issue Nov 19, 2024 · 5 comments

Comments

@dantownsend
Copy link
Member

There is an example .env file, but it's best define the environment variables in the Dockerfile too. They can have default values.

For example

ENV DB_PORT=5432
@sinisaos
Copy link
Member

@dantownsend I didn't understand how to add sensitive information as ENV to Dockerfile. For DB_PORT that's fine (but maybe user run on different port and that can easily change in .env file and run thru docker-compose), but what about DB_USERNAME, DB_PASSWORD etc? If the user do not use docker-compose, I find it useful to only run sensitive information with the Docker cli as in this comment.
Docker also has SECRETS, but we can add secrets only via the command line?

@dantownsend
Copy link
Member Author

@sinisaos When running a container in production, all of the platforms for running containers (e.g. Kubernetes, Amazon ECS) let you inject secrets as environment variables in some way. These secrets are for Docker Swarm, just one way of running containers in production. I wouldn't concern yourself with these.

So I wouldn't worry about it. From our perspective, secrets are just environment variables, like any others. If running it locally, then you can pass the secrets in via the command line like docker run piccolo_admin -e DB_PASSWORD=abc123.

@sinisaos
Copy link
Member

@dantownsend I see. Thanks for explanation. I'm sorry, but I've never had a chance to get a job as a professional developer so I don't know how things really work in real production environments, so I'll leave it up to you if that's not a problem. Thanks.

@dantownsend
Copy link
Member Author

@sinisaos No problem - you've done a great job. I've been really into Docker for a super long time, which is why I'm mentioning these things, but it's mostly small details.

@sinisaos
Copy link
Member

@dantownsend Great. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

2 participants