DEV Community

Chris Arter
Chris Arter

Posted on

2

A no-fuss Laravel + Docker starter repo

This starter repo was born out of frustration of getting docker working with Laravel. Hopefully this will save you some headache!

First, clone the repo here: https://github.com/christopherarter/Quick-Laravel-Docker-Starter

Prerequisites:

  1. PHP 7.1 (minimum)
  2. Composer install guide
  3. Docker install guide
  4. Docker Compose install guide

Get started

  1. Clone this repo and navigate to the repo folder. Run composer create-project --prefer-dist laravel/laravel my-app
  2. Run mv my-app/* my-app/.* ./ && rm -rf my-app
  3. Change the values in your .env to 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 docker-compose up

When you run docker ps, you should see your service running locally at http://localhost:9000

To run migrations and commands that interact with the database you need to be inside the laravel web app container.

Run 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 .env file.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay