Public | Automated Build

Last pushed: 3 months ago
Short Description
Docker image for Magento
Full Description

Docker image for Magento 1.x

This repo creates a Docker image for Magento 1.x.

Please note

The primary goal of this repo is to create Docker images for Magento 1.x development and testing, especially for extensions and themes development. It lacks essential support for production deployment, e.g. Varnish and Redis. Use this wisely for production deployment.

This repo is only for Magento 1.x. If you are looking for Magento 2.x, check out alexcheng1982/docker-magento2.

Magento versions

Version Git branch Tag name master latest

How to use

Use as standalone container

You can use docker run to run this image directly.

docker run -p 80:80 alexcheng/magento

Then finish Magento installation using web UI. You need to have an existing MySQL server.

Magento is installed into /var/www/html folder.

Use Docker Compose

Docker Compose is the recommended way to run this image with MySQL database.

A sample docker-compose.yml can be found in this repo.

version: '3.0'

    image: alexcheng/magento:
      - "80:80"
      - db
      - env
    image: mysql:5.6.23
      - db-data:/var/lib/mysql/data
      - env
    image: phpmyadmin/phpmyadmin
      - "8580:80"
      - db

Then use docker-compose up -d to start MySQL and Magento server.

Magento sample data

Sample data is not supported for Magento 1.8 any more.

Magento installation script

A Magento installation script is also provided as /usr/local/bin/install-magento. This script can install Magento without using web UI. This script requires certain environment variables to run:

Environment variable Description Default value (used by Docker Compose - env file)
MYSQL_HOST MySQL host mysql
MYSQL_DATABASE MySQL db name for Magento magento
MYSQL_USER MySQL username magento
MYSQL_PASSWORD MySQL password magento
MAGENTO_LOCALE Magento locale en_GB
MAGENTO_TIMEZONE Magento timezone Pacific/Auckland
MAGENTO_DEFAULT_CURRENCY Magento default currency NZD
MAGENTO_URL Magento base url http://local.magento
MAGENTO_ADMIN_FIRSTNAME Magento admin firstname Admin
MAGENTO_ADMIN_LASTNAME Magento admin lastname MyStore
MAGENTO_ADMIN_EMAIL Magento admin email
MAGENTO_ADMIN_USERNAME Magento admin username admin
MAGENTO_ADMIN_PASSWORD Magento admin password magentorocks1

If you want to use install-magento script and this images is started as a standalone container using docker run, make sure these environment variables are passed in docker run with -e switch.

After Docker container started, use docker ps to find container id of image alexcheng/magento, then use docker exec to call install-magento script.

docker exec -it <container id> install-magento

If Docker Compose is used, you can just modify env file in the same directory of docker-compose.yml file to update those environment variables.

After calling install-magento, Magento is installed and ready to use. Use provided admin username and password to log into Magento backend.

If you use default base url (http://local.magento) or other test url, you need to modify your host file to map the host name to docker container. For Boot2Docker, use boot2docker ip to find the IP address.

Important: If you do not use the default MAGENTO_URL you must use a hostname that contains a dot within it (e.g, otherwise the Magento admin panel login won't work.

Redis Cache

If you want to use Redis as Cache backend see comments in Dockerfile and bin/install-magento


Modman is a Magento module manager that allows you to leave your work siloed from the actual Magento codebase via symlinks. With modman, you can sync plugin or theme work without keeping a persistent volume (or using a hidden volume).

# from htdocs
modman init
modman link /path/to/plugin

And to update symlinks:

modman deploy
Docker Pull Command
Source Repository