3 - Run a Docker Virtual host on your machine, if you haven't already:
- If you are on Linux OS: your IP Address is `127.0.0.1` because the containers run directly on your localhost.
-**On Windows & MAC:** run `docker-machine start default`
- If you are on MAC or Windows and using the **docker-machine**: start your docker machine then type `docker-machine ip {vm-name-here}`. *(The default IP is 192.168.99.100)*
- If you are on MAC or Windows and using **boot2docker**: type `boot2docker ip` when boot2docker is up.
4 - Open your hosts file `/etc/hosts`.
>If the host "default" does not exist, create it using:
><br>
>`docker-machine create -d virtualbox default`
```bash
-**On Linux:** skip this step :) you don't need a virtual host, since Docker runs locally on your machine.
sudo nano /etc/hosts
```
5 - Map your `Docker IP` to the `laravel.dev` domain, by adding the following to the `hosts` file.
<br>
4 - Find your Docker IP address:
```bash
-**On Windows & MAC:** run `docker-machine ip default`
xxx.xxx.xxx.xxx laravel.dev
<br>
```
*(The default IP is 192.168.99.100)*
Don't forget to replace the `xxx.xxx.xxx.xxx` with your Docker IP Address.
-**On Linux:** your IP Address is `127.0.0.1`
6 - In the new created `docker` folder in step 2, open the `docker-compose.yml` file to replace the `xxx.xxx.xxx.xxx` with your Docker IP Adress as well.
> For **boot2docker** users: run `boot2docker ip` *(when boot2docker is up)*.
7 - Open your Laravel's `.env` file and set the `DB_HOST` to `laravel.dev` instead of the default `127.0.0.1`.
<br>
5 - Open your Laravel's `.env` file and set the `DB_HOST` to your `{Docker-IP}` instead of the default `127.0.0.1`:
```env
```env
DB_HOST=laravel.dev
DB_HOST=xxx.xxx.xxx.xxx
```
```
8 - Finally run the containers. **Make sure you are in the `docker` folder** before running this command.
> I am representing the `{Docker-IP}` with `xxx.xxx.xxx.xxx` for the purpos of this documentation.
<br>
6 - Finally let's run the containers. **Make sure you are in the `docker` folder** before running this command:
```bash
```bash
docker-compose up -d
docker-compose up -d
```
```
You can run `docker-compose up` (without **-d**) if you don't want to run the containers in the background.
*"Note: 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 to your local machine.*
*"Note: Only the first time you run this command, it will take up to 5 minutes (depend on your connection speed) to download the images to your local machine.*
> Debugging: in case you faced a problem with the docker mahcine here, run this command in your current terminal session `eval "$(docker-machine env {vm-name-here})"`.
> Debugging: in case you faced a problem with the docker mahcine here, run this command in your current terminal session `eval "$(docker-machine env default)"`
9 - Open your browser and visit `http://laravel.dev`
<br>
7 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`).
> Debugging: in case you faced an error here, it might be that you forget to provide some permissions for Laravel, so try running the following command on the Laravel root directory:
> Debugging: in case you faced an error here, run this command from the Laravel root directory: