我找不到我把我的文件放在哪里,这样ngnix就可以解释我的文件了。所有的容器都在工作,当我把localhost:8080放在这里时,这里是我的docker-compose.yml
web:
  image: nginx
  volumes:
   - ./templates:/etc/nginx/templates
  ports:
   - "8080:8080"
  environment:
   - NGINX_HOST=foobar.com
   - NGINX_PORT=8080
php:
       image: php:7.0-fpm
       expose:
           - 9000
       volumes_from:
           - app
       links:
           - elastic
app:
       image: php:7.0-fpm
       volumes:
           - .:/src
elastic:
       image: elasticsearch:2.3
       volumes:
         - ./elasticsearch/data:/usr/share/elasticsearch/data
         - ./elasticsearch/logs:/usr/share/elasticsearch/logs
       expose:
         - "9200"
       ports:
         - "9200:9200"有人能帮帮我吗?
发布于 2020-07-07 10:00:54
PHP和Nginx docker镜像需要挂载相同的卷。
version: '3'
services:
  nginx:
    image: nginx:alpine
    volumes:
      - ./app:/app
      - ./nginx-config/:/etc/nginx/conf.d/
    ports:
      - 80:80
    depends_on:
      - php
  php:
    image: php:7.3-fpm-alpine
    volumes:
     - ./app:/app在上面的编写文件中,代码放在主机的app文件夹下。
树
├── app
│   ├── helloworld.php
│   └── index.php
├── docker-compose.yml
└── nginx-config
    └── default.conf您的Nginx config应该使用docker服务网络连接php-fpm容器。
server {
    index index.php index.html;
    server_name php-docker.local;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /app/;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}或者,您可以尝试Github中的工作示例。
git clone https://github.com/Adiii717/dockerize-nginx-php.git
cd dockerize-nginx-php;
docker-compose up现在打开浏览器
http://localhost/helloworld.php
https://stackoverflow.com/questions/62760505
复制相似问题