Env variables in static xml files

I just started to use Docker and I find it’s wonderful. I tried to build a 2 containers environment for Magento, first container for apache and second for mysql. I linked the two containers together and I installed Magento on the apache container, using as DB Host the Mysql container. I obtained the ip of the linked mysql container from the env variable typing “env” on the apache container. It works fine, but the problem is that Magento saves the ip of the mysql server in the local.xml file. If I rebuild the mysql container it obtains a new ip address and magento stops to work until I update the local.xml file. Working on a php setting file (i.e. in wordpress) i can use the function getenv("MYSQL_PORT_3306_TCP_ADDR") to dynamically obtain the correct ip address, but what can I do if it’s saved in a static file xml file like in Magento?

  • Debian Docker config file
  • Do I need my own server if I move my Elastic Beanstalk app to use Docker?
  • How to setup default environment quickly in Docker?
  • docker container not finding the unix socket
  • On Windows how the docker host connect to docker containers?
  • How to pull layers one by one in Docker?
  • Docker does not release port inside container when tomcat service is stopped
  • Motivation for putting Docker containers inside an AWS EC2 instance
  • OS X Docker does not set repo name nor tag after build
  • Selenium Grid with Docker set Language for Firefox
  • Docker-compose setup mongodb with data and a nodejs server
  • Using Laradock, the “display_errors” flag is not working
  • One Solution collect form web for “Env variables in static xml files”

    I found it! When a container is linked to another through –link option, docker automatically add an entry in the container /etc/hosts, with the alias and the ip address of the just linked container!

    172.17.0.2  mysql 9e37a5c0a444 my-mysql
    

    I have only to substitute the IP address of the mysql server with the hostname (mysql or my-mysql) and it works also when the IP address is changing

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.