Before Docker is popular, there are usually two options to build a development environment: one is to install packages using an integrated development environment such as WAMP, XAMPP, Mamp, and the other is to install a Linux server using a normal virtual machine. Then install the package (for example: LNMP) by downloading one-click, or install the required software individually. Although the former is simple, but too inflexible, want to install additional software or version will be very troublesome or simply do not know how to start, the latter in addition to time and effort, excessive use of local resources, may cause the system to run slowly, and if you forget to generate snapshots in a timely manner, once the mistake, regret.
Luckily, Docker's here! It is simple and easy to use, flexible, convenient and quick, to sweep away all the disadvantages. If you want to know a little more about the star of the virtualization world, the Portal (Fast Understanding Docker).
Installing Docker
Usually developed in the environment is generally Mac or windows,linux for the time being no research, so next only to the first two to write the next step, these two platforms, the official recommended two installation methods: App and Toolkit (Toolbox). Note: The app has certain requirements for system version and configuration, and Windows requires you to install the Microsoft virtualization product Hyper-V, see the App link page.
APP
Https://docs.docker.com/docke ...
Https://docs.docker.com/docke ...
Tool Pack
Https://www.docker.com/produc ...
This is essentially the way you install Docker-engine, Docker-machine, Docker-compose, and VirtualBox (in addition to the Windows app) in your system. Because Docker is highly dependent on features and interfaces such as the cgroup,namespace provided by the Linux kernel, Mac and Windows platforms need to use docker-machine and virtual machines to create a Linux kernel running in the background.
The way I install it is to use brew directly on my Mac, and if you haven't installed Brew, execute the following code at the terminal:
/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
Packages required to install Docker:
Brew Install Docker Docker-machine docker-compose VirtualBox
Create a Docker-machine:
Docker-machine create-d VirtualBox Default
Note:-d specifies to use VirtualBox to create the default machine name
Tell the host how to find Docker-machine:
echo $ (docker-machine env) >>. ZSHRC
Note: Here's the. ZSHRC is my user profile, and if you use bash, you can change to. Bash_profile.
Start Docker-machine:
Docker-machine start default Compose your app
Docker-compose is a tool for defining and running complex Docker applications. You can define a multi-container application in the Docker-compose.yml file, then start with a single command, and all pre-defined operations will be automatically completed.
To use the third-party package on GitHub in order not to reinvent the wheel. Of course you can build every container image you need, and then use DOCKER-COMPOSE.YML to organize all of your containers, but this requires you to have a certain Linux base and Docker operating mechanism and related syntax.
I am learning to laradock this Docker-based development environment package and then delete some of the parts I think are not commonly used, modify some configurations, and add elasticsearch containers, eventually opening up my own warehouse devdock. Of course, it is recommended to use Laradock.
The container combinations currently supported by my warehouse:
Nginx, PHP-FPM, MySQL, Redis, MONGO, Apache2, memcached, Elasticsearch, workspace.
Note: Workspace and php-fpm are generally dependent on other containers, so they run automatically and do not need to be specified at startup.
Go to the parent directory of your app:
git clone https://github.com/RystLee/DevDock.git
Modify hosts
If the direct installation starts, is can through Docker ip:192.168.99.100, can directly access nginx, but generally for the convenience of memory, we will go to modify the Hosts file, add a:
192.168.99.100 Laravel.dev
Modify the site configuration file in your Nginx:
Find Nginx under the Devdock directory, modify the site configuration file under the Sites directory, customize the domain name by modifying the local hosts, and modify the corresponding domain name mapping under the Sites folder in the Nginx container.
server_name Laravel.dev
Install the Startup app
CD devdock docker-compose up-d nginx MySQL ... # Follow the container you want to use
Then, patiently waiting for the development environment to complete automatically, if there are errors in the middle, generally because of GFW, the network will not be smooth, re-execute one or two times good, after completion, open the browser, access: Http://laravel.dev can.
How do I use Docker to build a PHP development environment?