Why Apache container can't see PHP container?
by Jason.nix from LinuxQuestions.org on (#6KK2X)
Hello,
I have two YAML files as follows:
Code:version: '3.9'
networks:
phpnet:
driver: bridge
name: My_Network
services:
web:
image: nginx:latest
ports:
- '8080:80'
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- /var/www/html:/usr/share/nginx/html
networks:
- phpnet
depends_on:
- php-fpm
php-fpm:
image: php:8-fpm
volumes:
- /var/www/html:/usr/share/nginx/html/
- /var/www/html:/usr/local/apache2/htdocs/
networks:
- phpnetAnd:
Code:version: '3.9'
networks:
apache:
external: true
name: My_Network
services:
httpd:
ports:
- '80:80'
volumes:
- /var/www/html:/usr/local/apache2/htdocs/
- ./httpd.conf:/usr/local/apache2/conf/httpd.conf
image: 'httpd:latest'
networks:
- apacheThe network is also built by Docker:
Code:# docker network list
NETWORK ID NAME DRIVER SCOPE
b36954410da3 My_Network bridge local
385e912fff96 bridge bridge local
7b3a9c0ec7dd host host local
fb5635eda3c3 nginx-php_phpnet bridge local
d851ead577b7 none null local
b13678883aac redis_default bridge localBut:
Code:# curl http://172.20.2.58:8080/index.php
Testing PHP-FPM on Docker.
#
# curl http://172.20.2.58:80/index.php
<?php
echo "Testing PHP-FPM on Docker."
?>As you can see, Apache cannot compile PHP file. What is wrong?
Thank you.
I have two YAML files as follows:
Code:version: '3.9'
networks:
phpnet:
driver: bridge
name: My_Network
services:
web:
image: nginx:latest
ports:
- '8080:80'
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- /var/www/html:/usr/share/nginx/html
networks:
- phpnet
depends_on:
- php-fpm
php-fpm:
image: php:8-fpm
volumes:
- /var/www/html:/usr/share/nginx/html/
- /var/www/html:/usr/local/apache2/htdocs/
networks:
- phpnetAnd:
Code:version: '3.9'
networks:
apache:
external: true
name: My_Network
services:
httpd:
ports:
- '80:80'
volumes:
- /var/www/html:/usr/local/apache2/htdocs/
- ./httpd.conf:/usr/local/apache2/conf/httpd.conf
image: 'httpd:latest'
networks:
- apacheThe network is also built by Docker:
Code:# docker network list
NETWORK ID NAME DRIVER SCOPE
b36954410da3 My_Network bridge local
385e912fff96 bridge bridge local
7b3a9c0ec7dd host host local
fb5635eda3c3 nginx-php_phpnet bridge local
d851ead577b7 none null local
b13678883aac redis_default bridge localBut:
Code:# curl http://172.20.2.58:8080/index.php
Testing PHP-FPM on Docker.
#
# curl http://172.20.2.58:80/index.php
<?php
echo "Testing PHP-FPM on Docker."
?>As you can see, Apache cannot compile PHP file. What is wrong?
Thank you.