DEV Community

Cover image for Docker image for Laravel Applications

Docker image for Laravel Applications

grant_bartlett profile image Grant ・1 min read

This is my docker image for Laravel Applications, utilising docker-compose. If you have any feedback or suggestions please feel to make a pull request or leave a comment below.

Getting started

  • Clone the GitHub repo
  • In the top level and in the src folder rename .env.example to .env and configure your credentials.
  • Note: .env.example is included in two places, one for docker-compose to read and the other for Laravel to read.
  • Clone the latest Laravel into your src folder


Run the following in a terminal where docker-compose files are located.

    docker-compose -f docker-compose-dev.yml build app
    docker-compose -f docker-compose-dev.yml up -d 
    docker-compose -f docker-compose-dev.yml exec app ./


Run the following in a terminal:

    docker-compose build app
    docker-compose up -d
    docker-compose exec app ./

Other notes

  • Make sure DB_CONNECTION=mysql equals your service name in your docker-compose for mysql.
  • To run commands, use docker-compose exec, or enter the docker container: docker-compose exec app php artisan config:clear
  • The install script run at the end includes a list of post production actions Laravel suggests in their documentation to carry out, you can read more on those here.
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan key:generate

Discussion (0)

Editor guide