我创建了 docker-compose.yml,它可以在我的计算机(本地)上运行,但不能在服务器(docker swarm、portainer)上运行。容器 nginx 看不到 php-fpm。
码头工人-compose.yml:
version: "3"
services:
nginx:
image: nginx-php-test:8
ports:
- "8888:80"
restart: always
environment:
- ROLE=nginx #run nginx
fpm:
image: nginx-php-test:8
environment:
- ROLE=fpm #run php
restart: always
在 /etc/nginx/conf.d/default 中:
...
fastcgi_pass fpm:9000;
...
和 nginx-php-test 的 entrypoint.sh:
#!/bin/bash
if [ "$ROLE" == "nginx" ]; then
exec /usr/sbin/nginx
elif [ "$ROLE" == "fpm" ]; then
exec /usr/sbin/php-fpm7.4 -F
fi
如何连接到 fpm 容器?