Simplify Magento Development with Docker

clock-icon-white  5 min read

Docker simplifies the application development process by taking away monotonous configuration tasks. Using Docker as a container technology instead of virtual machine platforms helps address challenges related to the deployment, rapid scaling, infrastructure optimization.

However, the advantages of Docker for Magento development are apparent; it’s still perceived as something complex and unclear. Awareness of the Docker ecosystem may solve this problem and be valuable for DevOps and software developers. And as far as Docker is here to stay for long, let’s give it a chance.

Docker implies delivering software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files. To communicate, containers use well-defined channels – all of them share the services of a single operating system kernel. And this allows Docker to use fewer resources than virtual machines do.

Docker consists of a few components:

  • Build component – images
  • Run component – containers
  • Distribution component – registry to store, share, and manage container images

Drawing an analogy between Docker and object-oriented infrastructure

It’s a good idea to think about Docker in terms of object-oriented infrastructure. So, images in Docker are the same as classes in the object-oriented paradigm, and containers are our objects. Container represents the runtime instance of the image – we can make the exact parallel between an object and a class in object-oriented programming.

And now, we come to Compose, the tool that helps us define and run multi-container Docker apps. Compose is like a constructor, where we pass our configuration files (arguments), using a YAML file to configure the app’s services.

It brings numerous advantages. Docker adoption is increasing rapidly because of the reduced time to market, deployment velocity, and portability. But let’s look at the set of benefits from a technical point of view and find out why engineering teams facilitate the implementation of Docker. The causes lie in Docker advantages over local install development and over whole image or vagrant.

docker-advantages

Docker offers unified development infrastructure – an advantage over local install. For instance, one developer could be better than another in installing certain services and adding more PHP origins or PHP modules. Also, developers may be running on different versions of PHP or using different versions of engine.exe. With Docker, this is something from the past – we are all on the same page.

Another advantage is that we have a full stack of services. It’s effortless now to support different versions of PHP, SQL across projects. You can avoid separate installs and easily integrate external solutions, not caring about what technologies were used. Compared to Virtual Machines (Vagrant, Valet+), Docker saves space, works faster, simplifies management, and doesn’t require shared folders. For production use, Docker offers such advantages as scalability, cost savings, and CI/CD (continuous integration/continuous development).

docker-disadvantages

As any other technical solution, Docker has disadvantages and requires additional knowledge.

Compared to virtual machines, Docker containers have less overhead but at the same time not zero overhead.

You can apply Docker as a native system, on Linux. To use Docker on Mac and Windows, you’re required to install an additional software that takes care of virtualization.

Also, note that new Docker subscription tiers are applicable from 1 September. Companies may have mixed feelings about a paid subscription, and part of them will relinquish Docker in favor of free tools, e.g., Podman or Minikube.

docker-orchestration

We come to the point of Docker orchestration. With docker-compose, we can define services with their relations and configure them. Docker-compose was written on Python, and it is still the most common orchestrator for local development. Docker swarm can read docker-compose files, and the most prominent feature is that it can spin more than one container for a defined service at a certain time. It enables us to scale containers.

Kubernetes is a tool made by Google that helps to automate applications deployment. ECS is an elastic container service from Amazon, and ACI is an Azure container instances service.

sets-of-images-in-docker

Magento developers usually apply some sets of images. Let’s start with the set of containers provided by Mark Shust, whose sets of images are simple and easy to work with. Developers also resort to other options that’re closer to the main Docker idea: one container carries out a single, specific task.

Sets of images by Warden are valued for maturity, rich functionality, and additional tools like Traefik, Portainer, Dnsmasq, etc. In terms of disadvantages, Warden has a higher complexity and doesn’t cover PWAs.

Magento Cloud Docker is a part of the Magento Cloud Suite that enables deploying Magento Commerce to a local Cloud environment. Magento Cloud Docker remains a convenient and demanded tool, though additional complexity prevents its use.

Companies that intensively work with Docker should invest in their own sets of images as far as customization is adapted to their business goals.

In summary, perspectives of using Docker can be assessed in terms of business needs, production, and development. Software and DevOps engineers appreciate it because of the consistent ecosystem and flexibility. Nonetheless, the choice in favor of Docker should be well-considered.

LET’S TALK about how SoftServe can assist you in Magento development and what role is envisaged for Docker.