Installing Magento with Docker Compose on Windows

Hi,

I have heard and worked with docker several times, but never got a chance to write about the installation. So this time I wanted to share the steps I had taken to install docker on windows and then install Magento 2.4.3 on it.

So first I downloaded docker from this link https://docs.docker.com/desktop/windows/install/ and installed it on windows 10.

I also installed the WSL 2 backend for this docker setup. After installation when I run the command docker -v. The version was 20.10.13

In windows docker-compose comes with docker installation, unlike Linux. Then I downloaded Magento from https://magento.com/tech-resources/download

After that unzipped Magento into a directory, then inside the same directory created a file with the name docker-compose.yml and added the below contents.

version: '3'
services:
   web:
        image: webdevops/php-apache:7.4
        container_name: web
        restart: always
        user: application
        environment:
         - WEB_ALIAS_DOMAIN=local.magento.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:
         - .:/app:cached
        ports:
         - "80:80"
         - "443:443"
         - "32823:22"
        links:
         - mysql
   mysql:
        image: mysql:8.0
        container_name: mysql
        restart: "no"
        restart: always
        restart: on-failure
        restart: unless-stopped
        ports:
         - "3306:3306"
        environment:
         - MYSQL_ROOT_PASSWORD=root
         - MYSQL_DATABASE=magento
        volumes:
         - db-data:/var/lib/mysql  
   elasticsearch:
        container_name: es-container
        image: docker.elastic.co/elasticsearch/elasticsearch:7.16.0
        environment:
          - xpack.security.enabled=false
          - "discovery.type=single-node"
        networks:
          - es-net
        ports:
         - 9200:9200
   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        
networks:
   es-net:
        driver: bridge

After creating this file, run docker-compose config. This will check if there are any errors in your docker-compose.yml. You can check the configuration.

After we need to run the command docker-compose up

This should start all the containers for apache, mysql, elasticsearch and phpmyadmin.

Please note that docker on windows is probably not as fast as wamp on windows. But if you have to check something quickly, this is a good option.

One thought on “Installing Magento with Docker Compose on Windows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.