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?

  • Docker Compose: Change env variables
  • make causes core dump when entering an existing container
  • Share Existing Host Directory with Docker Container?
  • How do I point a docker image to my .m2 directory for running maven in docker on a mac?
  • Docker: rails executable file not found in $PATH
  • Docker image build as AWS CodePipeline step
  • How do I use the git commit id as a docker image tag in maven?
  • How to configure spring interceptor to get called with every request
  • How can I run Win32OLE calls from ubuntu?
  • Wifi stopped working after docker installation on Linux
  • Docker for Windows not working
  • Dockerpy executing command to cat log file
  • 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.