This is a simple docker development kit for Laravel projects. It includes a Nginx web server, PHP, and MySql.
- Docker (lol)
git clone https://github.com/sami-sopas/laravel-docker-dev-kit.git
docker compose up -d --build
docker compose exec php bash
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache
chmod -R 775 /var/www/storage /var/www/bootstrap/cache
composer install
npm install
docker compose up -d
- Server: db
- Port: 3306
- Username: Depends on .env file
- Password: Depends on .env file
- Database: Depends on .env file
docker compose up -d
- Create and start the containersdocker compose build
- Build or rebuild servicesdocker compose down
- Stop and remove containers and networks (Data is preserved)docker compose stop
- Stop all servicesdocker compose restart
- Restart containersdocker compose exec <container> <command>
- Run a command in a specific container
-
Access the App container: Here you can run php artisan, composer, npm, git etc.
docker compose exec php bash
-
Access the MySql container: Here you can run mysql commands.
docker compose exec db bash
mysql -u <username> -p <password>
-
The
docker-compose.yml
file is configured to use the.env
file in the root directory. Make sure to update the.env
file with the correct values. -
To ensure data preservation, it is stored in the
.docker/db/data
directory. Deleting the information in this directory will reset the database. -
If you have a
.sql file
that you want to import to the database, you can copy the file to the.docker/db/backups
directory and run the following command:docker compose exec db bash
mysql -u <username> -p <password> <database> < /var/backups/<filename>.sql
-
The MySQL port is exposed to the host machine, allowing you to use a client like DBeaver to connect to the database.