You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a mention for Kubernetes and Swarm secrets management, and a link to blog explaining with env variables may not be the best option. Also added a warning that secrets shouldn't be included in code, and that `.env` file shouldn't be included in built images.
Copy file name to clipboardExpand all lines: docs/docs/04_docker_intro/04_in_depth_docker_tutorial/README.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,12 @@ Note that most of this is identical to the `Dockerfile` that you would create fo
108
108
109
109
Use the `-e ENV_NAME=env_value` flag with `docker run`.
110
110
111
+
:::caution Secrets in environment variables
112
+
Passing secrets like database connection strings or API keys to Docker containers can be done with environment variables, but it isn't the most secure way (the official Docker tutorial [will tell you more](https://diogomonica.com/2017/03/27/why-you-shouldnt-use-env-variables-for-secret-data/)).
113
+
114
+
Instead a better option is to use your orchestration framework's secrets management system (that's a mouthful). The two major options are [Kubernetes](https://kubernetes.io/docs/concepts/configuration/secret/) and [Swarm](https://docs.docker.com/engine/swarm/secrets/), and each have their own secrets management system. More info on this later on!
115
+
:::
116
+
111
117
## Networking between two containers
112
118
113
119
First create a network with:
@@ -231,6 +237,13 @@ Create a `.dockerignore` file in the root directory of your project (where `dock
231
237
```
232
238
node_modules
233
239
.venv
240
+
.env
234
241
*.pyc
235
242
__pycache__
236
-
```
243
+
```
244
+
245
+
:::danger Secrets in Docker images
246
+
Don't include any secrets (like database connection strings or API keys) in your code. For local development you can use a `.env` file, but don't include the `.env` file in your Docker image!
247
+
248
+
One of the benefits of Docker images is you can share them with others easily, but that's why you have to be very careful with what you include in them.
0 commit comments