docker - dynamically adding nginx container ip into phpfpm /etc/hosts file -
looking automatically add nginx container ip address inside phpfpm container /etc/hosts file.
inside yml file, have service called phpfpm, , know can use extra_hosts attribute assign values /etc/hosts file, don't know how dynamically call place nginx container ip.
nginx: build: ./nginx ports: - "80:80" - "443:443" volumes: - ../public/:/var/www/html/public/ container_name: nginx networks: - backend phpfpm: build: ./php-fpm volumes: - ../public/:/var/www/html/public/ container_name: phpfpm extra_hosts: - "test.local:nginx" <insert nginx ip test.local> networks: - backend
any thoughts on how this?
containers within compose file run on same network , can names. phpfpm
, nginx
in case. if need more names same service need use aliases
nginx: build: ./nginx ports: - "80:80" - "443:443" volumes: - ../public/:/var/www/html/public/ container_name: nginx networks: backend: aliases: - test.local phpfpm: build: ./php-fpm volumes: - ../public/:/var/www/html/public/ container_name: phpfpm networks: - backend
Comments
Post a Comment