A No Fuss Laravel & Docker Starter Repo
When I initially wanted to transition from Homestead & Vagrant to a containerized version of Laravel, I struggled to get it working. I Googled far and wide, and tried a ton of different "simple" walk throughs that were anything but.
This repo is what I wish I had run into during that search, and is now a good quick startup for developing Laravel applications. It's still a work in progress, so if you have suggestions to make it better (but still simple) I'm all ears, drop me a mention @ChrisArter.
To get started, head to https://github.com/christopherarter/Quick-Laravel-Docker-Starter
- Clone this repo and navigate to the repo folder. Run
composer create-project --prefer-dist laravel/laravel my-app
mv my-app/* my-app/.* ./ && rm -rf my-app
- Change the values in your
.envto the values below:
DB_CONNECTION=mysql DB_HOST=laravel_db DB_PORT=3306 DB_DATABASE=laravel DB_USERNAME=laravel_user DB_PASSWORD=myStrongPassword1234
The last step, run
When you run
docker ps, you should see your service running locally at
To run migrations and commands that interact with the database you need to be inside the laravel web app container.
docker ps and get the id of the laravel web container. Next, run
docker exec -it <container-id> /bin/bash and you should be at
/var/www/app. You may now run artisan commands to interact with the database.
Connecting to your database with a database tool
To connect with this database using tools like MySQL Workbench, DB Beaver or TablePlus, you can access it with the
3305 port, username and password you specified in your