Skip to content

This repository helps you set up your Laravel projects using Docker.

Notifications You must be signed in to change notification settings

devsoli/docker-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-laravel

This repository helps you set up your Laravel projects using Docker, even if you are not familiar with Docker.

Services list

  • laravel app
  • nginx web server
  • mysql database

Setup

1. Clone the repository

first, clone the repository:

git clone https://github.com/devsoli/docker-laravel.git
cd docker-laravel

2. Create the environment file

copy the .env.example file to .env:

cp .env.example .env

config database connection in .env file:

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=password

3. Build app service

docker-compose build app

4. Run Docker Compose

to start the services, run:

docker-compose up -d

This command will run the Docker containers in the background.

5. Install dependencies

Enter the app container and install Composer dependencies:

docker-compose exec app composer install

6. Set the application key

Set the application key:

docker-compose exec app php artisan key:generate

7. Migrate the database

Migrate the database:

docker-compose exec app php artisan migrate

8. Access the application

After successfully running the above commands, your Laravel application should be accessible at http://localhost.

Useful commands

  • View logs:
docker-compose logs -f
  • Stop services:
docker-compose down
  • Access the container:
docker-compose exec app bash

Common issues

  • Ports are already in use: Make sure that ports 80 and 3306 are not being used by another service.
  • Permissions: If you encounter file permission issues, try the following commands:
sudo chown -R $USER:$USER .

If you encounter any issues or have any questions, please open a new issue in the Issues section.


I hope this guide helps you easily set up your Laravel projects with Docker.

About

This repository helps you set up your Laravel projects using Docker.

Topics

Resources

Stars

Watchers

Forks

Languages