I dockerized a laravel project with apache and mysql using the following configuration :
Dockerfile :
FROM php:8.2-apache
WORKDIR /var/www/html
# Mod Rewrite
RUN a2enmod rewrite
# Linux Library
RUN apt-get update -y && apt-get install -y
libicu-dev
libmariadb-dev
unzip zip
zlib1g-dev
libpng-dev
libjpeg-dev
libfreetype6-dev
libjpeg62-turbo-dev
libpng-dev
# Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# copy laravel project
COPY ./application /var/www/html
# grant permission
RUN chown -R www-data:www-data /var/www/html
RUN docker-php-ext-install mysqli pdo pdo_mysql
docker-compose.yml :
version: '3'
services:
laravel-docker:
container_name: laravel-docker
build:
context: .
ports:
- 9000:80
mysql_db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: nawarni
ports:
- 3306:3306
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 9001:80
environment:
- PMA_ARBITRARY=1
In docker i ran this command docker-compose up -d --build
Inside the laravel-docker container i typed these commands :
composer install
php artisan key:generate
php artisan migrate
php artisan serve
At this point everything worked well and my DB is created and the server is running
But then when i test my APIs in Postman i get 404 Not Found