Setting up Magento 2 on Windows might sound complex, but with Docker, the process becomes significantly easier. This guide explains how to install Magento 2.4 on windows using Docker , making it accessible even if you’re new to containerization.
Table of Contents
Steps to Install Magento 2.4 on Windows Using Docker
Download and Install Docker for Windows
- Start by downloading Docker for Windows from the official Docker installation guide. Follow the instructions provided to complete the installation.
Install Magento 2.4.
- Once Docker is installed, open a command prompt and navigate to your desired local folder (e.g.,
E:\magento\magento2
). To install Magento 2.4, run the following command - composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.6 magento2
This will install Magento 2.4.6 in your local directory, ready for configuration.
- Once Docker is installed, open a command prompt and navigate to your desired local folder (e.g.,
Configure PHP Settings
- To avoid memory issues during the Magento installation, modify the
user.ini
file located in your Magento folder (e.g.,E:\magento\magento2\user.ini
). Set thememory_limit
to 2048M
- To avoid memory issues during the Magento installation, modify the
Download Docker Compose File
- You’ll need a
docker-compose.yml
file to run Magento on Docker. Download it from this GitHub repository.
- You’ll need a
Place the Docker Compose File
- Copy the downloaded
docker-compose.yml
file into the Docker installation directory, usually located at"C:\Program Files\Docker\Docker"
on your Windows machine.
- Copy the downloaded
Set Up Magento Using Docker
- Now that everything is in place, open a command prompt in the Docker installation directory. Run the following commands to start the Docker containers and begin Magento setup:
- docker-compose up -d –build
- docker exec -it web bash
- ls
- cd app
- Once Docker is up and running, open your web browser and navigate to
http://localhost:8080/index.php
to access PHPMyAdmin and create a new database for Magento.
- Now that everything is in place, open a command prompt in the Docker installation directory. Run the following commands to start the Docker containers and begin Magento setup:
Install Magento via Command Line
- With the database created, return to the command prompt and run the following command to install Magento 2.4: php bin/magento setup:install –base-url=”https://mage246.domain.com/” –base-url-secure=”https://mage246.domain.com/” –db-host=”mysql” –db-name=”mage246″ –db-user=”root” –db-password=”root” –admin-firstname=”admin” –admin-lastname=”admin” –admin-email=”example@gmail.com” –admin-user=”admin” –admin-password=”admin123″ –language=”en_US” –currency=”USD” –timezone=”America/Chicago” –use-rewrites=”1″ –backend-frontname=”admin” –search-engine=elasticsearch7 –elasticsearch-host=”elasticsearch” –elasticsearch-port=9200
Final Magento Setup Commands
- After the installation completes, finalize the setup by running the following commands to optimize Magento for your Docker environment:
- php bin/magento s:up
- php bin/magento s:d:c
- php bin/magento s:s:d -f
- After the installation completes, finalize the setup by running the following commands to optimize Magento for your Docker environment:
Update Hosts File (if needed)
If Magento doesn’t load correctly, try adding an entry to your
hosts
file located atC:\Windows\System32\drivers\etc\hosts
.
By following this guide, you will successfully install Magento 2.4 on Windows using Docker, providing a flexible and efficient development setup.
Link to other related articles, such as “Setting Up Magento Development Environment.“
Leave a Reply