Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2.4.8 Docker Environment - Fresh Installation

A complete Docker-based environment for Magento 2 development, configured with Nginx, PHP-FPM, MySQL, Valkey, and OpenSearch.

🛠 Technology Stack

This environment is built with the following components:

Component Version Service Name
Magento 2.4.8 -
Nginx 1.18 mage248_nginx
PHP 8.3.19-fpm mage248_php
MySQL 8.0.41 mage248_mysql
Valkey (Redis) 8.0 mage248_valkey
OpenSearch 3.0 mage248_opensearch
PhpMyAdmin 5.2 mage248_phpmyadmin

🚀 Installation & Setup

1. Prepare Directory Structure

Create the necessary directories for persistence and logs:

mkdir -p db_data src logs/nginx osdata

2. Build & Start Containers

Build the PHP container and start the environment:

docker-compose build mage248_php --no-cache
docker-compose up -d

3. Setup Source Code

Install the Magento 2 source code into the src/ directory.

Option A: Using Composer (Recommended)

Access the PHP container:

docker exec -it mage248_php bash
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.8 ./
mv nginx.conf.sample nginx.conf

Note: This requires valid keys from repo.magento.com.

Option B: Existing Source Clone your repository or copy your existing Magento files into the src/ folder.

Access the PHP container:

docker exec -it mage248_php bash
composer install
mv nginx.conf.sample nginx.conf

4. Fresh Installation

Once the environment is running, update the base URLs in the database to match the local environment.

Database Connection

  • Host: 127.0.0.1 (Port: 3307)
  • User: magento
  • Password: magento123
  • Database: magento

Run the installation command:

bin/magento setup:install \
    --base-url=http://mage248.local \
    --db-host=mage248_mysql \
    --db-name=magento \
    --db-user=magento \
    --db-password=magento123 \
    --admin-firstname=admin \
    --admin-lastname=admin \
    --admin-email=admin@admin.com \
    --admin-user=admin \
    --admin-password=admin123 \
    --language=en_US \
    --currency=USD \
    --timezone=America/Chicago \
    --use-rewrites=1 \
    --search-engine=opensearch \
    --opensearch-host=opensearch \
    --opensearch-port=9200 \
    --opensearch-index-prefix=magento2 \
    --opensearch-timeout=15

📝 Usage Notes

  • PhpMyAdmin is available at http://localhost:81/index.php
  • Nginx listens on http://localhost:80 (or configured port)
  • MySQL is exposed on port 3307
  • Valkey is exposed on port 6379
  • OpenSearch is exposed on port 9200
  • Magento 2.4.8 is exposed on http://mage248.local

Build Images

docker-compose build mage248_php --no-cache

About

Docker for magento 2. Easy to set up.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages