I am using docker-compose to build a complete development stack.
The application needs a mysql server to work.
The mysql server is an external container setup by docker-compose:
mysql:
image: mysql:5.6
volumes:
- /data/mysql:/var/lib/mysql
- ./docker/mysql.d:/etc/mysql/conf.d
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: password
The application has its own docker-compose.yml and references the mysql container:
my-application:
build: . # the Dockerfile resides in the current folder
ports:
- "9180:80"
- "9543:443"
external_links:
- mysql_mysql_1:mysql
environment:
DOCKER_ENVIRONMENT: dev
DB_NAME: local_db
DB_PASS: password
DB_USER: root
DB_HOST: # how to set the mysql's IP address?
I cannot pass them in the docker-compose as it is dynamic.
I know that the application is aware of the mysql IP address, as I have certain variables set:
application-container$ env|grep ADDR
MYSQL_PORT_3306_TCP_ADDR=172.17.0.241
Yet this is not my required DB_HOST
.
Can I map the variable somehow to DB_HOST
or set it differently?