Reading time: 3 minutes
Why use Docker?
25 / 07 / 2017
Docker is gaining popularity with developers. Unlike virtualization, Docker runs applications in isolated containers. What advantage does this bring? Improved performance.
The container-based design enables selected application processes to be run in isolated containers, which are separate instances from the application perspective.
Each container has:
– a separate memory space
– a separate network interface with its IP address
– a separate disk space detached from the operating system and any dependencies
Let’s consider the scenario where we need a LAMP environment for one project and a JAVA environment for another. The two environments are separate processes, with only the necessary network connections between the containers. For the LAMP environment, Linux, Apache and PHP form one container, while MySQL is the other container, with the two containers linked by a network connection. For the JAVA environment, a separate unlinked container is created.
Normally, virtualizing these two environments would require two separate virtual machines consuming significant resources on the local machine.
If you work with several projects you would need a separate environment for each of them and, consequently, very powerful hardware. As mentioned before, since Docker does not use virtualization like Pupper or Vagrant, it requires less resources to run all environments. Without either virtualization or Docker, the development of multiple projects on a local machine would get really bothersome.
With Docker, you can use pre-built system, application and database images pulled from the public registry.
If you do not find what you need, you can always build your own image based on a generic one, with a barebones operating system or start-up environment.
Let’s sum up the benefits of using Docker:
– works with multiple projects simultaneously on a single machine;
– eliminates the “works on my machine” problem, as all environments are identical;
– runs isolated containers, side-by-side, to improve performance;
– provides new features for Linux and Windows Server in a faster and more secure way.
Magento 2 and Docker
During the download process you will be asked several questions:
1. New installation
– Get only DevBox and use local installation
2. Configure DevBox
– Select an operating system (Windows 10 Pro, macOS Yosemite 10.10.3 or above)
– Select Magento edition (CE, EE)
– Optionally include sample data
– Access keys (can be generated after logging into the Magento website)
– Other advanced options (install RabbitMQ, use Elasticsearch, Varnish for HTTP acceleration etc.)
A package for downloading and installing will be generated. The process can be launched using a single command (macOS), resulting in the installation of a new Magento 2 instance 🙂
If you have your own repositories or packages, e.g. on packagist.org, you can include them in the “composer.json” file, run the “composer update” command on your Docker container and get a working environment within 30 minutes.
Whether you work with a single project or multiple ones, consider using Docker. You can use it for creating new environments later, or set up the environment for another developer, a QA environment, a staging environment or even a production environment.