#### Enter a Container (SSH into a running Container)
If you do any change to any `dockerfile` make sure you run this command, for the changes to take effect:
1 - first list the current running containers with `docker ps`
```bash
docker-compose build
```
Optionally you can specify which container to rebuild (instead of rebuilding all the containers):
2 - enter any container using:
```bash
docker-compose build {container-name}
dockerexec-it{container-name} bash
```
3 - to exit a container, type `exit`.
<br>
<aname="Run-Artisan-Commands"></a>
#### Run Artisan Commands
You can run artisan commands and many other Terminal commands from the Workspace container.
1 - Make sure you have the workspace container running.
```bash
docker-compose up -d workspace // ..and all your other containers
```
2 - Find the Workspace container name:
<br>
<aname="Edit-Container"></a>
#### Edit default container configuration
Open the `docker-compose.yml` and change anything you want.
```bash
docker-compose ps
```
Examples:
3 - Enter the Workspace container:
Change MySQL Database Name:
```bash
docker exec-it{workspace-container-name} bash
```yml
environment:
MYSQL_DATABASE:laradock
```
4 - Run anything you want :)
Change Redis defaut port to 1111:
```bash
php artisan
```
```bash
Composer update
```
```bash
phpunit
```
```bash
laravel new blog
```yml
ports:
-"1111:6379"
```
<br>
<aname="Change-the-PHP-FPM-Version"></a>
#### Change the PHP-FPM Version
By default **PHP-FPM 7.0** is running.
>The PHP-FPM is responsible of serving your application code, you don't have to change the PHP-CLI version if you are planing to run your application on different PHP-FPM version.
1 - Open the `docker-compose.yml`.
2 - Search for `Dockerfile-70` in the PHP container section.
3 - Change the version number.
<br>
Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-70` with `Dockerfile-56`.
<aname="Edit-a-Docker-Image"></a>
#### Edit a Docker Image
Sample:
1 - Find the `dockerfile` of the image you want to edit,
<br>
example for `mysql` it will be `mysql/Dockerfile`.
```txt
php-fpm:
build:
context: ./php-fpm
dockerfile: Dockerfile-70
```
2 - Edit the file the way you want.
Supported Versions:
3 - Re-build the container:
- For (PHP 7.0.*) use `Dockerfile-70`
- For (PHP 5.6.*) use `Dockerfile-56`
- For (PHP 5.5.*) use `Dockerfile-55`
```bash
docker-compose build mysql
```
*If you find any bug or you have and suggestion that can improve the performance of any image, please consider contributing. Thanks in advance.*
4 - Finally rebuild the container
```bash
docker-compose build php
```
For more details about the PHP base image, visit the [official PHP docker images](https://hub.docker.com/_/php/).
<br>
<aname="Change-the-PHP-CLI-Version"></a>
#### Change the PHP-CLI Version
By default **PHP-CLI 7.0** is running.
>Note: it's not very essential to edit the PHP-CLI verion. The PHP-CLI is only used for the Artisan Commands & Composer. It doesn't serve your Application code, this is the PHP-FPM job.
The PHP-CLI is installed in the Workspace container. To change the PHP-CLI version you need to edit the `workspace/Dockerfile`.
Right now you have to manually edit the `Dockerfile` or create a new one like it's done for the PHP-FPM. (consider contributing).
<br>
<aname="Build-Re-build-Containers"></a>
#### 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):
```bash
docker-compose build {container-name}
```
<br>
<aname="Install-PHP-Extensions"></a>
#### Install PHP Extensions
Before installing PHP extensions, you have to decide whether you need for the `FPM` or `CLI` because each lives on a different container, if you need it for both you have to edit both containers.
The PHP-FPM extensions should be installed in `php-fpm/Dockerfile-XX`. *(replace XX with your default PHP version number)*.
<br>
The PHP-CLI extensions should be installed in `workspace/Dockerfile`.
...
...
@@ -438,72 +425,73 @@ To add an image (software), just edit the `docker-compose.yml` and add your cont
<br>
<aname="Edit-Container"></a>
#### Edit default container configuration
Open the `docker-compose.yml` and change anything you want.
Examples:
Change MySQL Database Name:
```yml
environment:
MYSQL_DATABASE:laradock
```
Change Redis defaut port to 1111:
```yml
ports:
-"1111:6379"
```
<br>
<aname="Use-custom-Domain"></a>
#### Use custom Domain (instead of the Docker IP)
Assuming your custom domain is `laravel.dev` and your current `Docker-IP` is `xxx.xxx.xxx.xxx`.
<aname="View-the-Log-files"></a>
#### View the Log files
The Nginx Log file is stored in the `logs/nginx` directory.
1 - Open your `/etc/hosts` file and map your `Docker IP` to the `laravel.dev` domain, by adding the following:
However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this:
```bash
xxx.xxx.xxx.xxx laravel.dev
docker logs {container-name}
```
2 - Open your Laravel's `.env` file and replace the `127.0.0.1` default values with your `{Docker-IP}`.
<br>
Example:
<aname="Laravel"></a>
### Laravel
```env
DB_HOST=xxx.xxx.xxx.xxx
```
3 - Open your browser and visit `{http://laravel.dev}`
<aname="Run-Artisan-Commands"></a>
#### Run Artisan Commands
Optionally you can define the server name in the nginx config file, like this:
You can run artisan commands and many other Terminal commands from the Workspace container.
```conf
server_namelaravel.dev;
1 - Make sure you have the workspace container running.
```bash
docker-compose up -d workspace // ..and all your other containers
```
2 - Find the Workspace container name:
```bash
docker-compose ps
```
3 - Enter the Workspace container:
<br>
<aname="View-the-Log-files"></a>
#### View the Log files
The Nginx Log file is stored in the `logs/nginx` directory.
```bash
docker exec-it{workspace-container-name} bash
```
However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this:
#### Enter a Container (SSH into a running Container)
<aname="PHP"></a>
### PHP
1 - first list the current running containers with `docker ps`
2 - enter any container using:
```bash
docker exec-it{container-name} bash
```
3 - to exit a container, type `exit`.
<aname="Install-PHP-Extensions"></a>
#### Install PHP Extensions
Before installing PHP extensions, you have to decide whether you need for the `FPM` or `CLI` because each lives on a different container, if you need it for both you have to edit both containers.
The PHP-FPM extensions should be installed in `php-fpm/Dockerfile-XX`. *(replace XX with your default PHP version number)*.
<br>
<aname="AddRemove-a-Docker-Container"></a>
#### Add/Remove a Docker Container
To prevent a container (software) from running, open the `docker-compose.yml` file, and comment out the container section or remove it entirely.
The PHP-CLI extensions should be installed in `workspace/Dockerfile`.
<br>
<aname="Edit-a-Docker-Image"></a>
#### Edit a Docker Image
<aname="Change-the-PHP-FPM-Version"></a>
#### Change the PHP-FPM Version
By default **PHP-FPM 7.0** is running.
1 - Find the `dockerfile` of the image you want to edit,
>The PHP-FPM is responsible of serving your application code, you don't have to change the PHP-CLI version if you are planing to run your application on different PHP-FPM version.
1 - Open the `docker-compose.yml`.
2 - Search for `Dockerfile-70` in the PHP container section.
3 - Change the version number.
<br>
example for `php` it will be `docker/php/dockerfile`.
Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-70` with `Dockerfile-56`.
2 - Edit the file the way you want.
Sample:
```txt
php-fpm:
build:
context: ./php-fpm
dockerfile: Dockerfile-70
```
Supported Versions:
- For (PHP 7.0.*) use `Dockerfile-70`
- For (PHP 5.6.*) use `Dockerfile-56`
- For (PHP 5.5.*) use `Dockerfile-55`
3 - Re-build the container:
4 - Finally rebuild the container
```bash
docker-compose build
docker-compose build php
```
*If you find any bug or you have and suggestion that can improve the performance of any image, please consider contributing. Thanks in advance.*
For more details about the PHP base image, visit the [official PHP docker images](https://hub.docker.com/_/php/).
<br>
<aname="Change-the-PHP-CLI-Version"></a>
#### Change the PHP-CLI Version
By default **PHP-CLI 7.0** is running.
>Note: it's not very essential to edit the PHP-CLI verion. The PHP-CLI is only used for the Artisan Commands & Composer. It doesn't serve your Application code, this is the PHP-FPM job.
The PHP-CLI is installed in the Workspace container. To change the PHP-CLI version you need to edit the `workspace/Dockerfile`.
Right now you have to manually edit the `Dockerfile` or create a new one like it's done for the PHP-FPM. (consider contributing).
<br>
<aname="Misc"></a>
### Misc
<aname="Run-Docker-Virtual-Host"></a>
#### Run a Docker Virtual Host
...
...
@@ -627,6 +678,10 @@ eval $(docker-machine env)
<br>
<aname="Find-Docker-IP-Address"></a>
#### Find your Docker IP Address
...
...
@@ -647,6 +702,48 @@ Your IP Address is `127.0.0.1`
<br>
<aname="Use-custom-Domain"></a>
#### Use custom Domain (instead of the Docker IP)
Assuming your custom domain is `laravel.dev` and your current `Docker-IP` is `xxx.xxx.xxx.xxx`.
1 - Open your `/etc/hosts` file and map your `Docker IP` to the `laravel.dev` domain, by adding the following:
```bash
xxx.xxx.xxx.xxx laravel.dev
```
2 - Open your Laravel's `.env` file and replace the `127.0.0.1` default values with your `{Docker-IP}`.
<br>
Example:
```env
DB_HOST=xxx.xxx.xxx.xxx
```
3 - Open your browser and visit `{http://laravel.dev}`
Optionally you can define the server name in the nginx config file, like this: