Skip to content

Instantly share code, notes, and snippets.

@malitta
Last active October 22, 2016 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malitta/99dae01e60f897903e322c1c3247a653 to your computer and use it in GitHub Desktop.
Save malitta/99dae01e60f897903e322c1c3247a653 to your computer and use it in GitHub Desktop.
Link web/db docker containers with a Laravel project

Setting up

Create the following files inside your Laravel project.

Add the following to the .gitignore file in the main project.

docker/.data
docker-compose.yml

Running the containers

Run using the following command. You can omit -p switch if the laravel project is named aptly.

docker-compose -p appname up -d

Resources

#docker/common.yml
version: '2'
services:
db:
image: mysql:5.7
volumes:
- "$PWD/docker/.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: Uw*tm8?
MYSQL_USER: webdbuser
MYSQL_PASSWORD: Abc123
MYSQL_DATABASE: webdb
web:
image: malitta/php
restart: always
volumes:
- "$PWD:/var/www/html"
version: '2'
services:
db:
extends:
file: docker/common.yml
service: db
web:
extends:
file: docker/common.yml
service: web
ports:
- 60000:80
depends_on:
- db
links:
- db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment