can I ask some help please I want to develop web application using docker nginx,mysql and php
but the problem is when I visit this in url app.dev it says unable to connect. I think my setting are something missing.
docker-compose.yml
version: "3.7"
services:
webapp:
build: .
webserver:
image: nginx
container_name: nginx-container
ports:
- "8080:80"
volumes:
- ./:/var/www/myapp
- ./default.conf:/etc/nginx/conf.d/default.conf
links:
- php
php:
image: php:7.2-fpm
container_name: php-container
db:
image: mysql
container_name: mysql-container
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./mysql-data:/var/lib/mysql
expose:
- 3306
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: rootpass
Dockerfile
FROM php:7.2-cli
COPY . /var/www/myapp
WORKDIR /var/www/myapp
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
cmd [ "php", "./index.php" ]
default.conf
server {
listen 80;
index index.php;
server_name app.dev;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/myapp;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}