From 457c5d4b1b79fdf742a231929e28917696e0f745 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Sat, 7 May 2016 05:03:07 +0300 Subject: [PATCH 1/2] update the readme file Support selecting your own containers in the docker compose command. --- README.md | 46 ++++++++++++++++++++++++++++++++++------------ docker-compose.yml | 20 ++++++++++---------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f476474f..1783b5ab 100644 --- a/README.md +++ b/README.md @@ -68,10 +68,10 @@ Instead of providing a full Virtual Machines, like you get with Vagrant, Docker - PHP - NGINX - MySQL +- Postgres - Redis - Data Volume - ## Requirements - Laravel ([Download](https://laravel.com/docs/master/installation)) @@ -114,23 +114,35 @@ DB_HOST=xxx.xxx.xxx.xxx [How to find my Docker IP Address?](#Find-Docker-IP-Address)
-2 - Run the containers: +2 - Run the Containers, (you can select the software's (containers) that you wish to run)
-*(Make sure you are in the `docker` folder before running this command)* +*Make sure you are in the `docker` folder before running the `docker-compose` command.* + +> Running PHP, NGINX and MySQL: ```bash -docker-compose up -d +docker-compose up -d php nginx mysql +``` + +Note: you can choose your own combination of software's (containers), another example: + +> Running PHP, NGINX, Postgres and Redis: + +```bash +docker-compose up -d php nginx postgres redis ``` ->*Only the first time you run this command, it will take up to 5 minutes (depend on your connection speed) to download the Docker Images on your local machine.*
3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`). -> **Debugging**: in case you faced an error here, run this command from the Laravel root directory: ->
-> `sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache` +
+**Debugging**: in case you faced an error here, run this command from the Laravel root directory: + +```bash +sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache +```
@@ -172,17 +184,26 @@ docker-compose rm -f
#### Build/Re-build Containers + +If you do any change to any `dockerfile` make sure you run this command, for the changes to take effect: + ```bash docker-compose build ``` +Optionally you can specify which container to rebuild (instead of rebuilding all the containers), example rebuilding `PHP`: +```bash +docker-compose build php +```
#### Use Redis in Laravel -Open your Laravel's `.env` file and set the `REDIS_HOST` to your `Docker-IP` instead of the default `127.0.0.1` IP. +1 - First make sure you run the Redis Container with the `docker-compose` command. + +2 - Open your Laravel's `.env` file and set the `REDIS_HOST` to your `Docker-IP` instead of the default `127.0.0.1` IP. ```env REDIS_HOST=xxx.xxx.xxx.xxx @@ -201,26 +222,27 @@ If you don't find the `REDIS_HOST` variable in your `.env` file. Go to the datab ], ``` -To enable Redis Caching and/or for Sessions Management. Also from the `.env` file set `CACHE_DRIVER` and `SESSION_DRIVER` to `redis` instead of the default `file`. +3 - To enable Redis Caching and/or for Sessions Management. Also from the `.env` file set `CACHE_DRIVER` and `SESSION_DRIVER` to `redis` instead of the default `file`. ```env CACHE_DRIVER=redis SESSION_DRIVER=redis ``` -Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first. +4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first. ```bash composer require predis/predis:^1.0 ``` -You can manually test it with: +5 - You can manually test it from Laravel with this code: ```php \Cache::store('redis')->put('laradock', 'awesome', 10); ``` +
#### Use custom Domain (instead of the Docker IP) diff --git a/docker-compose.yml b/docker-compose.yml index 14a24015..ed708726 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,6 +28,16 @@ services: links: - mysql +### DATA Container ########################################## + + data: + build: ./data + container_name: data + volumes: + - /var/lib/mysql + - /var/lib/postgresql/data + - /var/lib/redis + ### MySQL Container ######################################### mysql: @@ -67,14 +77,4 @@ services: ports: - "6379:6379" -### DATA Container ########################################## - - data: - build: ./data - container_name: data - volumes: - - /var/lib/mysql - - /var/lib/postgresql/data - - /var/lib/redis - ### Add more Containers below ############################### From 2b98b0b82e4a4f35b67151c6fd74fcf8e6b7a01e Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Sat, 7 May 2016 05:10:57 +0300 Subject: [PATCH 2/2] update the readme, include supported containers --- README.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1783b5ab..b5c11707 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Intro](#Intro) -- [Default Containers](#Default-Containers) +- [Supported Containers](#Supported-Containers) - [Requirements](#Requirements) - [Installation](#Installation) - [Usage](#Usage) @@ -24,7 +24,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Close all running Containers](#Close-all-running-Containers) - [Delete all existing Containers](#Delete-all-existing-Containers) - [Build/Re-build Containers](#Build-Re-build-Containers) - - [Use Redis in Laravel](#Use-Redis-in-Laravel) + - [Use Redis](#Use-Redis) - [Use custom Domain](Use-custom-Domain) - [Change the PHP Version](#Change-the-PHP-Version) - [Add/Remove a Docker Container](#AddRemove-a-Docker-Container) @@ -62,13 +62,13 @@ Seriously!!! Instead of providing a full Virtual Machines, like you get with Vagrant, Docker provides you **lightweight** Virtual Containers, that share the same kernel and allow to safely execute independent processes. - -## Default Containers + +## Supported Containers - PHP - NGINX - MySQL -- Postgres +- PostgreSQL - Redis - Data Volume @@ -132,6 +132,7 @@ Note: you can choose your own combination of software's (containers), another ex docker-compose up -d php nginx postgres redis ``` +Supported Containers: `php`, `nginx`, `mysql`, `postgres`, `redis`, `data`.
3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`). @@ -169,6 +170,12 @@ docker ps docker-compose stop ``` +To stop single container do: + +```php +docker-compose stop {container-name} +``` +
#### Delete all existing Containers @@ -178,7 +185,7 @@ docker-compose rm -f *Note: Careful with this command as it will delete your Data Volume Container as well. (if you want to keep your Database data than you should stop each container by itself as follow):* -`docker stop {container-name}` +
@@ -198,8 +205,8 @@ docker-compose build php
- -#### Use Redis in Laravel + +#### Use Redis 1 - First make sure you run the Redis Container with the `docker-compose` command.