E
E
EvgMul2020-12-07 09:13:23
Nginx
EvgMul, 2020-12-07 09:13:23

What is my docker-compose config error?

Hello. I have docker-compose.yml with the following content:

version: '3'

services:
  nginx:
    image: nginx:latest
    ports:
      - 80:80
    volumes:
      - ./:/var/www/html
      - ./docker/conf/nginx:/etc/nginx/conf.d
      - ./docker/nginx/logs:/var/log/nginx/
  php:
    build:
      dockerfile: Dockerfile
      context: ./
    volumes:
      - ./:/var/www/html
  db:
    image: mysql:latest
    environment:
      MYSQL_DATABASE: food
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
      MYSQL_PASSWORD: user
    ports:
      - 3306:3306
    volumes:
      - db_data:/var/lib/mysql
volumes:
  db_data:


When starting containers in the nginx logs, I see the following error:
2020/12/07 06:09:20 [crit] 19#19: *2 connect() to `unix:/var/run/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client`: 172.21.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "localhost"


Please tell me what I missed and how to fix this?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zohan1993, 2020-12-07
@EvgMul

docker exec -it php ls -l /var/run/
docker exec -it nginx ls -l /var/run/
if you use a socket, then it must be forwarded to the nginx container

---
listen = /var/run/php-fpm.sock
---
---
fastcgi_pass unix:/var/run/php-fpm.sock;
---

or use port
---
listen = 0.0.0.0:9000
---
---
fastcgi_pass php:9000;
---

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question