Why set up Magento 2 on Docker? The answer is simple:
- Docker’s environment reliability is impressive.
- Performance attributes are perfect for your Magento (Adobe Commerce) eCommerce website.
- Deployment velocity is novel even for an inexperienced user.
Both the platforms, Magento 2 and Docker, are powerful tools that can help level up your eCommerce website game. This coalition can make your store’s business operations smooth and robust. And, from a developer’s point of view, the fusion is a godsend. Mostly, when running Magento (Adobe Commerce) 2 with other virtual machines, some, if not all, the methods beget at least one drawback. In short, Docker makes website development easy by providing developers a way to run Magento (Adobe Commerce) 2 virtually everywhere because of minimal system requirements.
This article will essentially talk about how to set up Magento 2 on Docker. We will also provide a set-by-step guide for the integration process. Furthermore, we will offer a brief about Magento 2 and Docker for users new to these technologies.
Leverage this article to attain in-depth knowledge of both platforms and the process to set up Magento 2 on Docker — let’s begin!
Table of Contents
- What is Magento (Adobe Commerce) 2?
- What is Docker Engine?
- Setting up Magento 2 On Docker
What is Magento (Adobe Commerce) 2?
Magento (Adobe Commerce) 2 was officially released in 2015 as an upgrade over Magento (Adobe Commerce) 1. The new platform, Magento (Adobe Commerce) 2, offers better services to its users in terms of secured payment gateways, extension updates, and a self-service environment that requires less service support from developers.
Currently, Magento (Adobe Commerce) 2 has two different versions/editions based on user requirements and needs: Magento (Adobe Commerce) 2 Open Source and Magento (Adobe Commerce) 2 Commerce.
For now, Magento (Adobe Commerce) 2 is considered to be the best possible eCommerce platform solution. Over 1.2 million websites run using this platform. With this platform, you can easily change your website’s content, looks, and add multiple functionalities using extensions present on Magento (Adobe Commerce) Marketplace.
Some extended benefits of Magento (Adobe Commerce) 2 as an eCommerce solution are as follows:
- Magento (Adobe Commerce) 2 is known for its high-performing attributes: A website’s slow loading speed can result in lost business for an eCommerce platform. It has been estimated that if your website takes more than three seconds to load, the bounce rate increases by 50% — that’s 50% less profit. By default, Magento (Adobe Commerce) 2 takes advantage of Varnish Cache integration, an HTTP accelerator technology. The technology provides a seamless user experience to the website’s visitors.
- Customization features help persuade more customers: With Magento (Adobe Commerce) 2, you can easily change offers on specific products, add limited offer countdowns, stock availability, gift coupons, and more. You can also make product descriptions creative by adding rich media too.
- SEO friendliness: Today, for eCommerce stores boosting their organic search metrics is the way forward. Because research suggests that organic search drives the most website traffic. And, only SEO best practices can help you achieve that missing little competitive edge. Magento (Adobe Commerce) 2’s primary attraction is in its SEO-friendly design. It allows users to create SEO-friendly URLs and upload styles — including Meta titles, Related keywords, SEO descriptions, and much more.
- Magento (Adobe Commerce) Marketplace offers the best tools to make the customer experience smoother: Magento (Adobe Commerce) Marketplace is a host to a multitude of website extensions that can help you create website visits and user experience better. The extensions can help you with data security, secured payment gateways, a smooth search bar experience, and much more.
- Omnichannel Marketplace presence: With Magento 2, you can expand your market reach by creating an omnichannel presence on other marketplaces such as Amazon and eBay. This ability makes possible new revenue streams a reality for business owners.
Easy, simpler way to move all your customer data!
Hevo is a fully managed no-code data Pipeline-as-a-Service platform that helps you integrate and load data from 100+ different sources to a destination of your choice. Using Hevo requires a minimal learning curve, and can be set-up in just a few minutes.Get Started with Hevo for free
Check out some of the cool features of Hevo:
- Completely Automated: The Hevo platform can be set-up in just a few minutes and requires minimal maintenance.
- Real-Time Data Transfer: Hevo provides real-time data migration, so you can have analysis-ready data always.
- 100% Complete & Accurate Data Transfer: Hevo’s robust infrastructure ensures reliable data transfer with zero data loss.
- Scalable Infrastructure: Hevo has in-built integrations for 100+ sources (including 40+ Free Data Sources) like Snowflake, that can help you scale your data infrastructure as required.
- 24/7 Live Support: The Hevo team is available round the clock to extend exceptional support to you through chat, email, and support calls.
- Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
- Live Monitoring: Hevo allows you to monitor the data flow so you can check where your data is at a particular point in time.
What is Docker Engine?
Docker Engine was released eight years ago as open-source software. Today, it’s a set of Platform-as-a-Service products that help developers build, test, and deploy applications in no time. Docker uses OS-level virtualization to assemble software services into containers. The process is known as containerization. The reason Docker is famous is because of the fact that it makes the process of containerization easy. It provides developers tools with which they can develop, deploy, execute, update and halt containers using only single code commands, saving crucial person-hours.
Some benefits of using Docker Engine are as follows:
- Multi-functionality & Cloud-friendliness means Enhanced Portability: Docker containers are not machine-specific and can run without changes done for a desktop, cloud, or data center environment. The recent update of Docker works well with IaaS providers, too — like Microsoft Azure and OpenStack.
- Consistency in online/offline environments: While developing in an offline developing climate, many consistency errors occur. With Docker, it’s not the case.
- Application development simplified: The container technology eases the process of developing software services by providing all-in-one packages for a suitable runtime environment.
- Secured Operations: Cross-processes isolation is the property that enables separate workflow inside each container in a secured fashion. The functionality works as a firewall for your software service application, as even if your application is attacked by malicious software or hacker, it does not affect other applications present on the other Docker containers.
Setting up Magento 2 On Docker
Before beginning with the Magento 2 on Docker set-up process, let’s familiarize you with the prerequisites:
- Download and install Docker into your system.
- Download and install Composer. Here is the preferred way to manage Magento (Adobe Commerce) 2.
- Download Magento (Adobe Commerce) 2 Open Source metapackage.
Let’s begin with the set-up process…
Step 1: Plan a docker-compose.yml file
- Choose a location on your system memory to assign the place for Docker configuration files. Consider this location to begin with, /path/to/docker
- Open a new .txt document, choose any text editor you like. And copy and paste the code given below in the new file:
version: '3' services: web: image: webdevops/php-apache-dev:ubuntu-16.04 container_name: web restart: always user: application environment: - WEB_ALIAS_DOMAIN=local.domain.com - WEB_DOCUMENT_ROOT=/app/pub - PHP_DATE_TIMEZONE=EST - PHP_DISPLAY_ERRORS=1 - PHP_MEMORY_LIMIT=2048M - PHP_MAX_EXECUTION_TIME=300 - PHP_POST_MAX_SIZE=500M - PHP_UPLOAD_MAX_FILESIZE=1024M volumes: - /path/to/magento:/app:cached ports: - "80:80" - "443:443" - "32823:22" links: - mysql mysql: image: mariadb:10 container_name: mysql restart: always ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=magento volumes: - db-data:/var/lib/mysql phpmyadmin: container_name: phpmyadmin restart: always image: phpmyadmin/phpmyadmin:latest environment: - MYSQL_ROOT_PASSWORD=root - PMA_USER=root - PMA_PASSWORD=root ports: - "8080:80" links: - mysql:db depends_on: - mysql volumes: db-data: external: false
- In line 8, change the domain title with the name you created earlier
- In line 17, change the ‘/path/to/magento’ with the absolute path to the Magento (Adobe Commerce) file. Leave everything as it is
- Save the new file as /path/to/docker/docker-compose.yml
Step 2: Starting your virtual machine
- Remember, you still need to open your terminal with /path/to/docker
- Start the virtual machine. You will notice Dicker will start downloading the images and will take a few minutes to do it. But in the future, it will only take a few seconds to accomplish.
docker-compose up -d --build
- Make sure that your virtual machine is running properly. In your web browser, open 127.0.0.1:8080. You will see phpMyAdmin. If yes, the connection was successful.
Step 3: Installing Magento (Adobe Commerce) 2
- Access the command line in your Docker web container’s command line.
docker exec -it web bash
- Navigate the web document root
- Deploy sample data (this part is optional)
php bin/magento sampledata:deploy
- Before you copy and paste the code provided below, replace the command values in lines 2 and 6 with your own’s. In lines, 7-8 change the placeholder domain as you mentioned earlier.
php bin/magento setup:install --admin-firstname=John --admin-lastname=Doe --email@example.com --admin-user=admin --admin-password='SomePassword123' --base-url=https://local.domain.com --base-url-secure=https://local.domain.com --backend-frontname=admin --db-host=mysql --db-name=magento --db-user=root --db-password=root --use-rewrites=1 --language=en_US --currency=USD --timezone=America/New_York --use-secure-admin=1 --admin-use-security-key=1 --session-save=files --use-sample-data
- Open https://local.domain.com on your web browser. It might take a few minutes to load, but that is because the cache has not been created yet, the next processes will be faster. The first time, the browser might present you with a security alert because the web container uses a self-signed SSL certificate.
And that is it! The setup process for Magento (Adobe Commerce) 2 on Docker was finished.
That said, let’s also list out some helpful Docker information & commands to get the most out of your Magento (Adobe Commerce) 2 project.
- Docker information
- Even if you restart your virtual machine your database will be present as it is. This is due to the fact that a data volume is contained in the docker-compose.yml file.
- To connect to other databases or Sequel Pro, access is provided through 127.0.0.1:3306. With username: root, password: root, database name: magento.
- Docker Commands
- Spin Up: docker-compose up -d –build
- Tear Down: docker-compose down
- Connect to web container CLI: docker exec -it web bash
- Connect to database container CLI: docker exec -it mysql bash
In this article, we successfully discussed the set-up process for Magento (Adobe Commerce) 2 on Docker. And we also talked, in brief, about Magento2 and Docker and what they have in offer for today’s businesses, i.e., exclusive features and editions.
The Magento (Adobe Commerce) 2 on Docker set-up process can prove advantageous for today’s eCommerce platforms for reasons varying from the ease in application development to data security, from malicious attacks or malware software. Moreover, Docker makes Magento developments much more efficient. That is why so many enterprise-level Magento (Adobe Commerce) eCommerce stores are built on top of Docker.
Smoother website functions mean more customer footfall and the collection of more operations data. This makes it a challenge for large eCommerce websites to transfer data from one source to another. Hevo Data is a No-Code Data Pipeline that can accurately transfer data from a collection of 100+ sources including Magneto (Adobe Commerce) 2 into a Data Warehouses or a destination of your choice.Visit our Website to Explore Hevo
Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand.