Reputation: 503
I'm testing docker compose with Nginx and php-fpm, but this fail. My docker-compose.yml:
version: '2'
services:
nginx:
container_name: nginx
build:
context: ./dockerfiles/nginx/
dockerfile: Dockerfile
volumes:
- ./project/:/usr/share/nginx/html/
ports:
- "8000:80"
links:
- php
php:
container_name: php-fpm
image: php:7-fpm
volumes:
- ./project/:/var/www/html/
ports:
- "9000:9000"
This is my dockerfile Nginx:
FROM nginx:latest
COPY config/default.conf /etc/nginx/conf.d/
And dafault.conf file:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php(/|$) {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
when I try localhost: 8000 returns the following message:
"File not found."
but, the index.php is in the project/ path.
that I am wrong?
Upvotes: 2
Views: 2742
Reputation: 721
I think you need to use volumes_from in your nginx container in the compose file, now you have in nginx:
volumes:
- ./project/:/usr/share/nginx/html/
And in php
volumes:
- ./project/:/var/www/html/
They should be the same.
Upvotes: 3