justadev
justadev

Reputation: 1496

Docker compose no connection between containers using socket

I am trying to use https://github.com/markshust/docker-magento. Following the instructions, the setup includes a nginx container in the frontend, which is suppose to connect with a php-fpm in the backend.

Containers:

ubuntu@DESKTOP-HED9HVG:/mnt/c/Users/Me$ docker ps -a
CONTAINER ID        IMAGE                                      COMMAND                  CREATED             STATUS              PORTS                                                                                        NAMES
8db110d5737a        markoshust/magento-nginx:1.18-4            "/docker-entrypoint.…"   2 hours ago         Up 2 hours          80/tcp, 0.0.0.0:80->8000/tcp, 0.0.0.0:443->8443/tcp                                          localdev_app_1
74ff9e11646a        markoshust/magento-php:7.4-fpm-5           "docker-php-entrypoi…"   2 hours ago         Up 2 hours          9000-9001/tcp                                                                                localdev_phpfpm_1       

As far as I can understand the code, the phpfpm is listening on the docker socket.

Nginx upstream:

upstream fastcgi_backend {
  server unix:/sock/docker.sock;
}

php-fpm.conf:

:
listen = /sock/docker.sock
:

this is the docker-compose.yaml file

But I can't get it to work.

php-fpm is working:

app@74ff9e11646a:~/html$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
app          1  0.0  0.2 222828 33168 ?        Ss   06:57   0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
app          6  0.0  0.0 222828 10412 ?        S    06:57   0:00 php-fpm: pool www
app          7  0.0  0.0 222828 10348 ?        S    06:57   0:00 php-fpm: pool www
app          8  0.0  0.0 222828 10348 ?        S    06:57   0:00 php-fpm: pool www
app          9  0.0  0.0 222828 10348 ?        S    06:57   0:00 php-fpm: pool www

However,from nginx to phpfpm, there is ping, but there is no telnet:

/var/www/html # ping phpfpm
PING phpfpm (172.19.0.7): 56 data bytes
64 bytes from 172.19.0.7: seq=0 ttl=64 time=0.128 m

/var/www/html # telnet phpfpm 9000
telnet: can't connect to remote host (172.19.0.7): Connection refused
/var/www/html # telnet phpfpm 9001
telnet: can't connect to remote host (172.19.0.7): Connection refused

I am windows10 wsl2. Any idea what I should check?

Upvotes: 1

Views: 317

Answers (1)

Andrew
Andrew

Reputation: 12809

You are telling PHP-FPM to use a socket for communication, that's why it's not listening on TCP / port 9000.

It can either listen on a TCP Port, OR use a socket, not both.

Upvotes: 1

Related Questions