Docker-compose running a Laravel app using: php, nginx and mysql docker containers. Made for the purpose of studying docker-compose.
Brief summary of how the containers are structured:
-
NGINX: Responsible for serving the Laravel application. It is based on the official nginx image and exposes port 80.
-
PHP: Responsible for running the PHP code of the Laravel application. It is based on the official PHP image and has a Dockerfile that installs the necessary PHP extensions and dependencies. It also mounts the Laravel application code as a volume.
-
MySQL: Responsible for running the MySQL database. It is based on the official MySQL image and has environment variables that define the root password and the name of the database.
docker-compose up -d --build
docker-compose exec php php /var/www/artisan migrate --seed
curl http://localhost:8080
- Built this docker-compose structure following this fantastic article, with minor changes in the Dockerfile's php version and laravel .env DB values.
- Do not forget to give the mysql user the correct permissions!