LaraDock -- Docker LaravelHomestead: enables you to easily run Laravel applications in Docker.

Source: Internet
Author: User
LaraDock -- Docker LaravelHomestead: enables you to easily run Laravel applications in Docker. what is LaraDock?

LaraDock is similar to Laravel Homestead, but runs in Docker rather than Vagrant. LaraDock allows us to easily run the Laravel application in Docker within several seconds.

LaraDock is committed to making the development process simple, contains a pre-packaged Docker image to provide us with a first-class development environment without the need to manually install PHP, Nginx, MySQL, Redis, and other software that may be used to run Laravel applications or tools.

Docker vs Vagrant

Here, we will first understand what Docker is: Docker is an open-source engine that allows you to easily create a lightweight, portable, and self-sufficient container for any application. Containers compiled and tested on a notebook can be deployed in a production environment in batches, including VMs, bare metal, OpenStack clusters, and other basic application platforms.

Next we will discuss why Docker is used instead of Vagrant: From the time point, it takes several minutes for Vagrant to provide virtual machines, while Docker takes only a few seconds. In addition, from the volume point of view, vagrant provides complete virtual machines, while Docker provides lightweight virtual containers that share the same kernel and allow running in independent processes.

LaraDock built-in software

Software included in LaraDock's built-in Docker image:

  • Nginx + PHP
  • MySQL
  • Redis
  • Beanstalked
  • Data Volume

You can edit these images: https://github.com/LaraDock/docker-images

System requirements
  • Laravel (installation)
  • Docker Toolbox (download)
  • Git (download)
  • Composer (download)
Tutorial

1) install any version of Laravel or use an existing Laravel project.

2) clone LaraDock to the docker directory under the root directory of the Laravel project:

Docker git clone https://github.com/LaraDock/laradock.git

3) after installing Docker Toolbox, place the installation directory to the system path and view the Docker IP address:

  • If you are using Linux: the default IP address is 127.0.0.1, because the container can run locally
  • If you are using a Mac or Windows and are using docker-machine: Enter the docker-machine ip {vm-name-here} command to view the information (the default IP address is 192.168.99.100)
  • If you are using Mac or Windows and are using boot2docker: Enter the boot2docker ip command to view

Here we use the Windows environment and docker-machine. the IP address can be viewed as follows:

The visible IP address is 192.168.99.100.

4) map the Docker IP address to laravel. dev in the hosts file:

xxx.xxx.xxx.xxx laravel.dev

Do not forget to replace xxx. xxx with your Docker IP address. here, my IP address is 192.168.99.100.

5) in the newly created docker directory in step 2 above, open the docker-compose.yml file and replace xxx. xxx with your Docker IP address.

6) open the. env file of the Laravel project and set DB_HOST and REDIS_HOST to laravel. dev:

DB_HOST=laravel.devREDIS_HOST=laravel.dev

If the REDIS_HOST variable is not found in. env, replace 127.0.0.1 with laravel. dev in the database configuration file config/database. php:

'redis' => [    'cluster' => false,    'default' => [        'host' => 'laravel.dev',        'port' => 6379,        'database' => 0,    ],],

If you want to use Redis as the cache/Session driver, open the. env file and set CACHE_DRIVER and SESSION_DRIVER to redis:

CACHE_DRIVER=redisSESSION_DRIVER=redis

7) run the following command in the docker Directory:

docker-compose up

If you want to run the container in the background, you can use the docker-compose up-d command:

Note: the first time you run the preceding command, it will take about 5 minutes (depending on your network speed) to download the image to your local device.

8) access the http://laravel.dev in the browser.

For more information, see the official documentation: http://laradock.github.io/laradock/

GitHub address

LaraDock: https://github.com/LaraDock/laradock

Docker-Images: https://github.com/LaraDock/docker-images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.