diff --git a/README.md b/README.md index 8c3ec99..eaa5612 100644 --- a/README.md +++ b/README.md @@ -16,34 +16,36 @@ It's like Laravel Homestead but for Docker instead of Vagrant. - [Intro](#Intro) - [Features](#features) + - [Supported Containers](#Supported-Containers) - [What is Docker](#what-is-docker) - [What is Laravel](#what-is-laravel) - [Why Docker not Vagrant](#why-docker-not-vagrant) - [LaraDock VS Homestead](#laradock-vs-homestead) -- [Supported Containers](#Supported-Containers) - [Requirements](#Requirements) - [Installation](#Installation) - [Usage](#Usage) - [Documentation](#Documentation) - - [List current running Containers](#List-current-running-Containers) - - [Close all running Containers](#Close-all-running-Containers) - - [Delete all existing Containers](#Delete-all-existing-Containers) - - [Build/Re-build Containers](#Build-Re-build-Containers) - - [Run Artisan Commands](#Run-Artisan-Commands) - - [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version) - - [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version) - - [Install PHP Extensions](#Install-PHP-Extensions) - - [Add/Remove a Docker Container](#AddRemove-a-Docker-Container) - - [Add more Software's (Docker Images)](#Add-Docker-Images) - - [Edit default container configuration](#Edit-Container) - - [Use custom Domain](#Use-custom-Domain) - - [View the Log files](#View-the-Log-files) - - [Use Redis](#Use-Redis) - - [Enter a Container (SSH into a running Container)](#Enter-Container) - - [Edit a Docker Image](#Edit-a-Docker-Image) - - [Run a Docker Virtual Host](#Run-Docker-Virtual-Host) - - [Find your Docker IP Address](#Find-Docker-IP-Address) - + - [Docker](#Docker) + - [List current running Containers](#List-current-running-Containers) + - [Close all running Containers](#Close-all-running-Containers) + - [Delete all existing Containers](#Delete-all-existing-Containers) + - [Enter a Container (SSH into a running Container)](#Enter-Container) + - [Edit default container configuration](#Edit-Container) + - [Edit a Docker Image](#Edit-a-Docker-Image) + - [Build/Re-build Containers](#Build-Re-build-Containers) + - [Add more Software's (Docker Images)](#Add-Docker-Images) + - [View the Log files](#View-the-Log-files) + - [Laravel](#Laravel): + - [Run Artisan Commands](#Run-Artisan-Commands) + - [Use Redis](#Use-Redis) + - [PHP](#PHP) + - [Install PHP Extensions](#Install-PHP-Extensions) + - [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version) + - [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version) + - [Misc](#Misc) + - [Run a Docker Virtual Host](#Run-Docker-Virtual-Host) + - [Find your Docker IP Address](#Find-Docker-IP-Address) + - [Use custom Domain](#Use-custom-Domain) @@ -79,7 +81,7 @@ docker-compose up nginx mysql -## Supported Containers +### Supported Containers - PHP-FPM (7.0 - 5.6 - 5.5) - NGINX @@ -165,6 +167,7 @@ git submodule add https://github.com/LaraDock/laradock.git *If you are not already using Git for your Laravel project, you can use `git clone` instead of `git submodule`.* +
#### B - From scratch (Install LaraDock and Laravel): *If you don't have any Laravel project yet, and you want to start your Laravel project with Docker.* @@ -265,6 +268,13 @@ sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache ## Documentation + + + +### Docker + + + #### List current running Containers ```bash @@ -277,6 +287,9 @@ docker-compose ps ``` + + +
#### Close all running Containers @@ -292,6 +305,9 @@ docker-compose stop {container-name} + + +
#### Delete all existing Containers @@ -304,6 +320,83 @@ docker-compose down + + + +
+ +#### Enter a Container (SSH into a running Container) + +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`. + + + + + + + +
+ +#### 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" +``` + + + + + + + + +
+ +#### Edit a Docker Image + +1 - Find the `dockerfile` of the image you want to edit, +
+example for `mysql` it will be `mysql/Dockerfile`. + +2 - Edit the file the way you want. + +3 - Re-build the container: + +```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.* + + + + + + + + + +
#### Build/Re-build Containers @@ -321,7 +414,45 @@ docker-compose build {container-name} + + +
+ +#### Add more Software's (Docker Images) + +To add an image (software), just edit the `docker-compose.yml` and add your container details, to do so you need to be familiar with the [docker compose file syntax](https://docs.docker.com/compose/compose-file/). + + + + + + + + + +
+ +#### View the Log files +The Nginx Log file is stored in the `logs/nginx` directory. + +However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this: + +```bash +docker logs {container-name} +``` + + + + + +
+ +### Laravel + + + + #### Run Artisan Commands @@ -362,149 +493,6 @@ laravel new blog -
- -#### 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. -
-Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-70` with `Dockerfile-56`. - -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` - - -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/). - - - - -
- -#### 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). - - - - -
- -#### 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)*. -
-The PHP-CLI extensions should be installed in `workspace/Dockerfile`. - - - -
- -#### Add more Software's (Docker Images) - -To add an image (software), just edit the `docker-compose.yml` and add your container details, to do so you need to be familiar with the [docker compose file syntax](https://docs.docker.com/compose/compose-file/). - - - -
- -#### 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" -``` - - - -
- -#### 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}`. -
-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: - -```conf -server_name laravel.dev; -``` - - - - -
- -#### View the Log files -The Nginx Log file is stored in the `logs/nginx` directory. - -However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this: - -```bash -docker logs {container-name} -``` - @@ -558,50 +546,113 @@ composer require predis/predis:^1.0 -
- -#### Enter a Container (SSH into a running Container) -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`. - - -
- -#### 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.
- -#### Edit a Docker Image + +### PHP -1 - Find the `dockerfile` of the image you want to edit, + + + + + + +#### 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)*.
-example for `php` it will be `docker/php/dockerfile`. +The PHP-CLI extensions should be installed in `workspace/Dockerfile`. -2 - Edit the file the way you want. -3 - Re-build the container: -```bash -docker-compose build + + + + + + +
+ +#### 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. +
+Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-70` with `Dockerfile-56`. + +Sample: + +```txt +php-fpm: + build: + context: ./php-fpm + dockerfile: Dockerfile-70 ``` -*If you find any bug or you have and suggestion that can improve the performance of any image, please consider contributing. Thanks in advance.* +Supported Versions: + +- For (PHP 7.0.*) use `Dockerfile-70` +- For (PHP 5.6.*) use `Dockerfile-56` +- For (PHP 5.5.*) use `Dockerfile-55` + + +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/). + + + + +
+ +#### 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). + + + + + + + + + + + +
+ +### Misc + + + + + #### Run a Docker Virtual Host @@ -627,6 +678,10 @@ eval $(docker-machine env) + + + +
#### Find your Docker IP Address @@ -647,6 +702,48 @@ Your IP Address is `127.0.0.1` + + + +
+ +#### 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}`. +
+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: + +```conf +server_name laravel.dev; +``` + + + + + + + + + +
## Contributing