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?

  • What to do with pid files in a docker container
  • dotnet core Docker app hangs on Synology build
  • Docker error at higher core counts on a multi core machine
  • docker-compose how to run container with bind 1-to-1 ports on ip aliasing interface
  • how docker container can get IP where docker swarm runs
  • Discourse Docker and Apache on one server
  • What is the difference between “docker logs” and “docker attach”?
  • Visual Studio publish to custom Docker container fails due to non-existent Dockerfile directory
  • Docker Experimental FeaturesToolbox
  • wordpress container cannot connect to mariadb container
  • How to access scripts in different Docker containers from a single place?
  • Best practice for building docker for Python - requirements file OR install individually
  • 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!  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.