Hi,
I am new to Docker and created an image using pre-baked images nginx:alpine and php:fpm-alpine. These are two containers and connected them via internal network bridge. Here is my docker-compose.yml file
version: "3"
services:
nginx:
build:
context: .
dockerfile: nginx/Dockerfile
ports:
- "8080:80"
networks:
- internal
volumes:
- ./data/:/var/www/html/
- ./logs/nginx:/var/log/nginx/
php:
image: php:fpm-alpine
networks:
- internal
volumes:
- ./data/:/var/www/html/
- ./logs/php.log:/var/log/fpm-php.www.log
networks:
internal:
driver: bridge
Now, I composed up this yml file and can see containers up and running. I saved and loaded the php container image and then tried to access the app. I get 502 bad gateway error.
this is default.conf file where I am configuring the port
server {
listen 0.0.0.0:80;
root /var/www/html;
location / {
index index.php index.html;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}
docker-compose.yml file for the loaded image.
version: "3"
services:
nginx:
image: php_with_nginx_nginx:latest
ports:
- "8080:80"
networks:
- internal
volumes:
- ./data/:/var/www/html/
- ./logs/nginx:/var/log/nginx/
php:
image: phpnginxload:latest
networks:
- internal
volumes:
- ./data/:/var/www/html/
- ./logs/php.log:/var/log/fpm-php.www.log
ports:
- "9000:9000"
networks:
internal:
driver: bridge
When checked logs, there is no php service in the container
7020:~/php_with_nginx$ docker exec -it php_with_nginx_php_1 sh
/ # netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.11:38961 0.0.0.0:* LISTEN
udp 0 0 127.0.0.11:33901 0.0.0.0:*
there is no port 9000 here...
/usr/sbin # php-fpm -F
sh: php-fpm: not found
/usr/sbin # php -v
sh: php: not found
/usr/sbin #
any pointers would be highly appreciated.