想要在我的phpfpm容器/ etc/hosts文件中自動添加nginx容器ip地址。動態添加nginx容器ip到phpfpm/etc/hosts文件
在我的yml文件中,我有一個名爲phpfpm的服務,並且我知道你可以使用extra_hosts屬性將值分配到/ etc/hosts文件中,但是我不知道如何動態調用放置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
有關如何做到這一點的任何想法?
是的,因爲有多個網站坐在指向phpfpm容器的nginx上,其中一個腳本想要對特定網站進行卷曲。所以我需要將域綁定到一個IP,以便它可以調用正確的文件。 – yohox3
因此,在你的代碼中,如果捲髮'test.local'沒有定義'extra_hosts'並且定義了別名,它就會工作 –
感謝這很好,我沒有看到他們有這個功能! – yohox3