docker-compose: parametrize containers with env_file and $environment_variables (MySQL use case)

preview_player
Показать описание
When creating a container, sometimes is necessary to parametrize data to be utilized by it. These parameters may include IP addresses (or URLs), user/system credentials and so on. This kind of parametrization is typically performed by defining environment variables during the build process.

Welcome to Talking about Computer Science!
Here we are going to show how to use environment variables in the docker-compose file and how to define this variables in a externa file through the usage of env_file parameter. The presented example is using a mysql server image.

Please feel free to ask and suggest another content to be presented.
Do you want to support? Just subscribe this channel.

0:00 Context
8:14 Then...
Рекомендации по теме
Комментарии
Автор

The thing is, when I am setting up the env_file while doing the build on Dockerfile I can't get this env_file being read, just the root-folder/.env. Most of the times people show this but never check if this really works, can you print it out the variables from another folder outside of the root folder? as on root folder is working, but when i switch to another folder, it reads only the .env file close to the docker-compose.yml file.

Can you help me out with this?

RafaelMendes-ywjm
Автор

Is there any way to encrypt env_file? I'am passing values in my project via environment variables and I dont want to share some passwords in plain text.

stanisawglegoa