Skip to content

Commit ab7f3d8

Browse files
committed
Merge remote-tracking branch 'LaraDock/master'
2 parents cd97ac0 + 2b98b0b commit ab7f3d8

2 files changed

Lines changed: 58 additions & 29 deletions

File tree

README.md

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
1515

1616

1717
- [Intro](#Intro)
18-
- [Default Containers](#Default-Containers)
18+
- [Supported Containers](#Supported-Containers)
1919
- [Requirements](#Requirements)
2020
- [Installation](#Installation)
2121
- [Usage](#Usage)
@@ -24,7 +24,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
2424
- [Close all running Containers](#Close-all-running-Containers)
2525
- [Delete all existing Containers](#Delete-all-existing-Containers)
2626
- [Build/Re-build Containers](#Build-Re-build-Containers)
27-
- [Use Redis in Laravel](#Use-Redis-in-Laravel)
27+
- [Use Redis](#Use-Redis)
2828
- [Use custom Domain](Use-custom-Domain)
2929
- [Change the PHP Version](#Change-the-PHP-Version)
3030
- [Add/Remove a Docker Container](#AddRemove-a-Docker-Container)
@@ -62,16 +62,16 @@ Seriously!!!
6262
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.
6363

6464

65-
<a name="Default-Containers"></a>
66-
## Default Containers
65+
<a name="Supported-Containers"></a>
66+
## Supported Containers
6767

6868
- PHP
6969
- NGINX
7070
- MySQL
71+
- PostgreSQL
7172
- Redis
7273
- Data Volume
7374

74-
7575
<a name="Requirements"></a>
7676
## Requirements
7777
- Laravel ([Download](https://laravel.com/docs/master/installation))
@@ -114,23 +114,36 @@ DB_HOST=xxx.xxx.xxx.xxx
114114
[How to find my Docker IP Address?](#Find-Docker-IP-Address)
115115

116116
<br>
117-
2 - Run the containers:
117+
2 - Run the Containers, (you can select the software's (containers) that you wish to run)
118118
<br>
119-
*(Make sure you are in the `docker` folder before running this command)*
119+
*Make sure you are in the `docker` folder before running the `docker-compose` command.*
120+
121+
> Running PHP, NGINX and MySQL:
120122
121123
```bash
122-
docker-compose up -d
124+
docker-compose up -d php nginx mysql
123125
```
124126

125-
>*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.*
127+
Note: you can choose your own combination of software's (containers), another example:
128+
129+
> Running PHP, NGINX, Postgres and Redis:
130+
131+
```bash
132+
docker-compose up -d php nginx postgres redis
133+
```
134+
135+
Supported Containers: `php`, `nginx`, `mysql`, `postgres`, `redis`, `data`.
126136

127137
<br>
128138
3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`).
129139

130140

131-
> **Debugging**: in case you faced an error here, run this command from the Laravel root directory:
132-
> <br>
133-
> `sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache`
141+
<br>
142+
**Debugging**: in case you faced an error here, run this command from the Laravel root directory:
143+
144+
```bash
145+
sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache
146+
```
134147

135148
<br>
136149

@@ -157,6 +170,12 @@ docker ps
157170
docker-compose stop
158171
```
159172

173+
To stop single container do:
174+
175+
```php
176+
docker-compose stop {container-name}
177+
```
178+
160179
<br>
161180
<a name="Delete-all-existing-Containers"></a>
162181
#### Delete all existing Containers
@@ -166,23 +185,32 @@ docker-compose rm -f
166185

167186
*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):*
168187

169-
`docker stop {container-name}`
188+
170189

171190

172191
<br>
173192
<a name="Build-Re-build-Containers"></a>
174193
#### Build/Re-build Containers
194+
195+
If you do any change to any `dockerfile` make sure you run this command, for the changes to take effect:
196+
175197
```bash
176198
docker-compose build
177199
```
200+
Optionally you can specify which container to rebuild (instead of rebuilding all the containers), example rebuilding `PHP`:
178201

202+
```bash
203+
docker-compose build php
204+
```
179205

180206

181207
<br>
182-
<a name="Use-Redis-in-Laravel"></a>
183-
#### Use Redis in Laravel
208+
<a name="Use-Redis"></a>
209+
#### Use Redis
184210

185-
Open your Laravel's `.env` file and set the `REDIS_HOST` to your `Docker-IP` instead of the default `127.0.0.1` IP.
211+
1 - First make sure you run the Redis Container with the `docker-compose` command.
212+
213+
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.
186214

187215
```env
188216
REDIS_HOST=xxx.xxx.xxx.xxx
@@ -201,26 +229,27 @@ If you don't find the `REDIS_HOST` variable in your `.env` file. Go to the datab
201229
],
202230
```
203231

204-
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`.
232+
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`.
205233

206234
```env
207235
CACHE_DRIVER=redis
208236
SESSION_DRIVER=redis
209237
```
210238

211-
Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first.
239+
4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first.
212240

213241
```bash
214242
composer require predis/predis:^1.0
215243
```
216244

217-
You can manually test it with:
245+
5 - You can manually test it from Laravel with this code:
218246

219247
```php
220248
\Cache::store('redis')->put('laradock', 'awesome', 10);
221249
```
222250

223251

252+
224253
<br>
225254
<a name="Use-custom-Domain"></a>
226255
#### Use custom Domain (instead of the Docker IP)

docker-compose.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ services:
2929
- mysql
3030
- postgres
3131

32+
### DATA Container ##########################################
33+
34+
data:
35+
build: ./data
36+
container_name: data
37+
volumes:
38+
- /var/lib/mysql
39+
- /var/lib/postgresql/data
40+
- /var/lib/redis
41+
3242
### MySQL Container #########################################
3343

3444
mysql:
@@ -68,14 +78,4 @@ services:
6878
ports:
6979
- "6379:6379"
7080

71-
### DATA Container ##########################################
72-
73-
data:
74-
build: ./data
75-
container_name: data
76-
volumes:
77-
- /var/lib/mysql
78-
- /var/lib/postgresql/data
79-
- /var/lib/redis
80-
8181
### Add more Containers below ###############################

0 commit comments

Comments
 (0)