11/22/2021»»Monday

Install Magento 2 Using Docker

The Most Popular Extension Builder for Magento 2

With a big catalog of 234+ extensions for your online store

If you are searching “How to set up Magento 2 on Docker” or “Set up Magento 2 on Docker”, you come to the right post.

Magento 2 is one of the powerful open-source eCommerce platforms that is used to manage all store’s processes like shipping, billing, checkout, and more. Docker is a development environment platform using an operating system (OS). The integration of Magento 2 and Docker platforms will make your online store more powerful and flexible.

The deployment phase. For Magento2 there is one, maybe two important commands executed during deployment: The predominant is bin/magento setup:upgrade –keep-generated to update the database.The.

This post will show you a step-by-step guide on How to Set Up Magento 2 on Docker.

Without further ado, let’s jump right into the details!

  • Mar 01, 2021 Setup Magento 2.4 with a Docker Container Upgrade or install Magento 2.4 in a Docker-isolated container for development. Doing this provides better elasticity and the ability to create separate instances for various purposes on a single underlying host machine.
  • In this tutorial we’ll learn how to install magento 2.4.x in CWP control panel. At the time of writing this tutorial CWP 7 (centos 7) have older version of MySQL server i.e. MariaDB 10.1 which is not supported by Magento 2.4.x. CWP on centos 8 is fully supported by magento since it have Mariadb 10.4. Without wasting time lets get started.
  • Install Magento 2 Using the Command Line. Download and Unzip the Latest Release to /data/web/magento2. Create a Database (In This Example, We Named the Database ‘magento2’, but You Can Name It However You Like) Enable the Magento 2 Management Tool.

Table of Contents

  • How to Set up Magento 2 on Docker
    • Some common prerequisites

Benefits of setting up Magento 2 on Docker

If you still wonder about Magento 2 and Docker integration, the following reasons can help you make a decision. Below are some fundamental reasons why you should set up Magento 2 on Docker.

  • Magento 2 is a free environment, easy to develop and implement.
  • Docker platform brings strong performance. Its portability and scalability are perfect for Magento 2 stores.
  • You can be easy to use and install.
  • You can set up Docker on your local machine and begin developing quickly.
  • This platform is reliable, and it makes the development of Magento and PHP applications easier.

How to Set up Magento 2 on Docker

Some common prerequisites:

Magento 2 Tutorial

Install Docker

Obviously, the first step you have to do is to download and install Docker. Now the Docker platform is available on all operating systems. Whether you are using any operating system, you can also install and start it up.

Install Composer

In many different ways to install and manage Magento 2, Composer is the first preferred choice to set up. Because installing any plugin/ platform via Composer is always accessible and quick compared to other ways. Besides, Composer also enables you to manage and install packages, run additional scripts after each update.

Download Magento 2

Install Magento 2 Using Docker

To download Magento 2 for stores, please follow the guide below:

  • You need to access Mageplaza to download Magento 2.
  • After logging in, navigate to Access Keys, and this time, please keep that window open because the keys are necessary for step 3.
  • Decide a location on your local machine that you want to put the website files to live.
  • Please open a command line terminal window. Please replace the placeholder path with the final path where you will install Magento, before copying and pasting the code below.
  • Please choose the version you want and press the download button. Afterward, you will be redirected to the directory where you installed the Magento, /path/to/magento.
  • At this point, please increase the PHP memory limit from the default value of 765M to 2048M.
  • Finally, select a domain name that you would like to access the site, then add it to your host’s file.

sudo -- sh -c 'echo '127.0.0.1 local.domain.com' >> /etc/hosts'

That’s all the prerequisites. Let’s explore 3 important steps !

Step 1: Generate a docker-composer.yml file

#1. You need to select a place to put your Docker configuration files. Refer this location as /path/to/docker.

#2. Next, open a new document.

#3. Now, click on “copy” and paste the following code into a new file:

#4. Navigate to line 8 and replace the domain name with the created domain before.

#5. On line 17, please replace /path/to/magento with the absolute path to the Magento files that you have downloaded before.

#6. Finally, in step 1, remember to save the new file as /path/to/docker/docker-compose.yml.

Step 2: Ready to start with your virtual machine

#1. In this step, you still need to open your terminal to /path/to/docker.

#2. It’s time to fire up your virtual machine. As soon as you spin up, it takes some minutes so that Dockers can download the images. After that, spin-ups in the future will take a few seconds.

docker-compose up -d --build

#3. Please make sure that everything is set up and run as per your plan. Then, you need to go to 127.0.0.1.8080 in your web browser, and you will see phpMyAdmin. Congrats, it’s successful if you can see it.

Docker

Step 3: Install Magento 2 in detail

It’s time to do the most important step. Let’s get going!

Install Magento 2 Using Docker Download

#1. Access your command line that contains your Docker web: docker exec -it web bash

#2. Please go-ahead to the web document root: cd /app

#3. Although this is an optional step, highly recommended: deploy sample data: php bin/magento sampledata:deploy

Magento 2 Download

#4. Install Magento 2. Remember copying and pasting the following command into the Docker terminal. Note that you must replace the values on lines 2-6 with your own details. On lines 7-8, please replace the placeholder domain with your created domain name before.

#5. Navigate to your website at https://local.domain.com or whatever domain you select. You need to spend some minutes loading the page when you access the website for the first time. The reason for this is that nothing is cached and the Magento system will automatically create files when loading the pages. Don’t worry, as the loading process will be quicker next time.

Additionally, as the web container applies a self-signed SSL certificate, you can get a security alert from the browser when visiting the URL for the first time.

#6. Congratulations! You succeed in setting up Magento 2 on Docker. Please remember that you can repeat this process for other projects through our step-by-step guide.

Install Magento 2 Docker Windows 10

Final thoughts

That’s it! Now you have Magento 2 and run it on the Docker environment. It’s straightforward to follow if you spend more time reading this guide carefully. We wish that this article will help you install Magento 2 on Docker and of course, it will bring your Magento 2 store more great benefits afterward.

If you see our article as useful, don’t forget to share it with your friends as we will give you more helpful information in the next blog.

Thanks a lot for reading!

Simple, powerful tools to grow your business. Easy to use, quick to master and all at an affordable price.

Get Started

Most Viewed Posts