希望在phpfpm容器/etc/hosts文件中自动添加nginx容器ip地址。
在我的yml文件中,我有一个名为phpfpm的服务,我知道可以使用extra_hosts属性将值分配到/etc/hosts文件中,但是我不知道如何动态地调用place the nginx容器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 to test.local>
networks:
- backend对如何做到这一点有什么想法吗?
发布于 2017-08-18 16:54:44
组成文件中的容器将在相同的网络上运行,您可以只使用它们的名称。你的例子是phpfpm和nginx。此外,如果您需要同一服务的多个名称,则需要使用别名
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发布于 2017-08-18 16:13:17
为什么需要Nginx Ip地址?您可以通过主机名nginx从phpfpm容器中调用nginx
https://stackoverflow.com/questions/45750752
复制相似问题