Docker Community Forums

Share and learn in the Docker community.

How to really link two containers?


(Ignazioc) #1

I have two container, one is running mysql and the second one is running apache2+php.
I used docker-compose to build and run the two containers.

On the apache container, I need the host, the username and the password to access to the mysql instance.
What should I do in this case? should I declare the three parameters as enviroment variable and pass throu the docker-compose.yml ?


(Michael Clifford) #2

As you stated, you could define them as environment variables and have them hardcoded into the docker-compose.yml file or you could use the env_file option of docker-compose.yml. That would allow you to have a file that contains all the environment variables you want to set in your apache container.