Introducing our new CEO Don Johnson - Read More

bitnami/magento

Verified Publisher

By VMware

Updated 5 months ago

🛑 DEPRECATED Bitnami container image for Magento

Image
Content Management System
Security
Web Servers
157

10M+

Bitnami package for Magento

🛑 Deprecation Notice

The Magento container is now deprecated. This image will no longer be released in our catalog, but already-released container images will persist in the registries.

After some months, this repository will be removed in favor of bitnami/magento-archived where all existing images can be found.

What is Magento?

Magento is a powerful open source e-commerce platform. With easy customizations and rich features, it allows retailers to grow their online businesses in a cost-effective way.

Overview of Magento Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

docker run --name magento bitnami/magento:latest

Warning: This quick setup is only intended for development environments. You are encouraged to change the insecure default credentials and check out the available configuration options in the Environment Variables section for a more secure deployment.

Why use Bitnami Images?

  • Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
  • With Bitnami images the latest bug fixes and features are available as soon as possible.
  • Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
  • All our images are based on minideb -a minimalist Debian based container image that gives you a small base container image and the familiarity of a leading Linux distribution- or scratch -an explicitly empty image-.
  • All Bitnami images available in Docker Hub are signed with Notation. Check this post to know how to verify the integrity of the images.
  • Bitnami container images are released on a regular basis with the latest distribution packages available.

Looking to use Magento in production? Try VMware Tanzu Application Catalog, the commercial edition of the Bitnami catalog.

How to deploy Magento in Kubernetes?

Deploying Bitnami applications as Helm Charts is the easiest way to get started with our applications on Kubernetes. Read more about the installation in the Bitnami Magento Chart GitHub repository.

Bitnami containers can be used with Kubeapps for deployment and management of Helm Charts in clusters.

Supported tags and respective Dockerfile links

Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page.

You can see the equivalence between the different tags by taking a look at the tags-info.yaml file present in the branch folder, i.e bitnami/ASSET/BRANCH/DISTRO/tags-info.yaml.

Subscribe to project updates by watching the bitnami/containers GitHub repo.

Get this image

The recommended way to get the Bitnami Magento Docker Image is to pull the prebuilt image from the Docker Hub Registry.

docker pull bitnami/magento:latest

To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.

docker pull bitnami/magento:[TAG]

If you wish, you can also build the image yourself by cloning the repository, changing to the directory containing the Dockerfile and executing the docker build command. Remember to replace the APP, VERSION and OPERATING-SYSTEM path placeholders in the example command below with the correct values.

git clone https://github.com/bitnami/containers.git
cd bitnami/APP/VERSION/OPERATING-SYSTEM
docker build -t bitnami/APP:latest .

How to use this image

Magento requires access to a MySQL or MariaDB database to store information. We'll use the Bitnami Docker Image for MariaDB for the database requirements.

Using the Docker Command Line

Step 1: Create a network

docker network create magento-network

Step 2: Create a volume for MariaDB persistence and create a MariaDB container

$ docker volume create --name mariadb_data
docker run -d --name mariadb \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env MARIADB_USER=bn_magento \
  --env MARIADB_PASSWORD=bitnami \
  --env MARIADB_DATABASE=bitnami_magento \
  --network magento-network \
  --volume mariadb_data:/bitnami/mariadb \
  bitnami/mariadb:latest

Step 3: Create volumes for Magento persistence and launch the container

$ docker volume create --name magento_data
docker run -d --name magento \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env MAGENTO_DATABASE_USER=bn_magento \
  --env MAGENTO_DATABASE_PASSWORD=bitnami \
  --env MAGENTO_DATABASE_NAME=bitnami_magento \
  --network magento-network \
  --volume magento_data:/bitnami/magento \
  bitnami/magento:latest

Access your application at http://your-ip/

Installing Magento extensions

There are a large number of Magento extensions used to add features to your Magento Stores. If you want to install an extension to your Magento container, these are the basic steps you need to take:

Step 1: Log into the container shell as root
docker exec -it magento /bin/bash
Step 2: Login as the web server user
su daemon -s /bin/bash
Step 3: Change directory to the Magento root
cd /bitnami/magento
Step 4: Follow the installation instructions for the extension. The Magento standard is to use composer
composer require <extension name>
php bin/magento module:enable <extension name>
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
Run the application using Docker Compose
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/magento/docker-compose.yml > docker-compose.yml
docker-compose up -d

Please be aware this file has not undergone internal testing. Consequently, we advise its use exclusively for development or testing purposes. For production-ready deployments, we highly recommend utilizing its associated Bitnami Helm chart.

If you detect any issue in the docker-compose.yaml file, feel free to report it or contribute with a fix by following our Contributing Guidelines.

Persisting your application

If you remove the container all your data will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should mount a directory at the /bitnami/magento path. If the mounted directory is empty, it will be initialized on the first run. Additionally you should mount a volume for persistence of the MariaDB data.

The above examples define the Docker volumes named mariadb_data and magento_data. The Magento application state will persist as long as volumes are not removed.

To avoid inadvertent removal of volumes, you can mount host directories as data volumes. Alternatively you can make use of volume plugins to host the volume data.

Mount host directories as data volumes with Docker Compose

This requires a minor change to the docker-compose.yml file present in this repository:

   mariadb:
     ...
     volumes:
-      - 'mariadb_data:/bitnami/mariadb'
+      - /path/to/mariadb-persistence:/bitnami/mariadb
   ...
   magento:
     ...
     volumes:
-      - 'magento_data:/bitnami/magento'
+      - /path/to/magento-persistence:/bitnami/magento
   ...
-volumes:
-  mariadb_data:
-    driver: local
-  magento_data:
-    driver: local
Mount host directories as data volumes using the Docker command line

Step 1: Create a network (if it does not exist)

docker network create magento-network

Step 2. Create a MariaDB container with host volume

docker run -d --name mariadb \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env MARIADB_USER=bn_magento \
  --env MARIADB_PASSWORD=bitnami \
  --env MARIADB_DATABASE=bitnami_magento \
  --network magento-network \
  --volume /path/to/mariadb-persistence:/bitnami/mariadb \
  bitnami/mariadb:latest

Step 3. Create the Magento container with host volumes

docker run -d --name magento \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env MAGENTO_DATABASE_USER=bn_magento \
  --env MAGENTO_DATABASE_PASSWORD=bitnami \
  --env MAGENTO_DATABASE_NAME=bitnami_magento \
  --network magento-network \
  --volume /path/to/magento-persistence:/bitnami/magento \
  bitnami/magento:latest

Configuration

Initializing a new instance

When the container is executed for the first time, it will execute the files with extensions .sh located at /docker-entrypoint-initdb.d.

Environment variables

Customizable environment variables

NameDescriptionDefault Value
MAGENTO_DATA_TO_PERSISTFiles to persist relative to the Magento installation directory. To provide multiple values, separate them with a whitespace.$MAGENTO_BASE_DIR
MAGENTO_HOSTMagento host domain or IP address.localhost
MAGENTO_ENABLE_HTTPSWhether to enable SSL to access the Magento store.no
MAGENTO_ENABLE_ADMIN_HTTPSWhether to use SSL to access the Magento administration panel.no
MAGENTO_EXTERNAL_HTTP_PORT_NUMBERPort to access Magento from outside of the instance using HTTP.80
MAGENTO_EXTERNAL_HTTPS_PORT_NUMBERPort to access Magento from outside of the instance using HTTPS.443
MAGENTO_FIRST_NAMEMagento user first name.FirstName
MAGENTO_LAST_NAMEMagento user last name.LastName
MAGENTO_MODEMagento mode.default
MAGENTO_EXTRA_INSTALL_ARGSExtra flags to append to the Magento 'setup:install' command call.nil
MAGENTO_ADMIN_URL_PREFIXURL prefix to access the Magento administration panel.admin
MAGENTO_DEPLOY_STATIC_CONTENTWhether to deploy Magento static content during the initialization, to optimize initial page load time.no
MAGENTO_KEEP_STATICWhether to keep the content of 'pub/static' folder during the initialization.no
MAGENTO_SKIP_REINDEXWhether to skip Magento re-index during the initialization.no
MAGENTO_SKIP_BOOTSTRAPWhether to perform initial bootstrapping for the application.no
MAGENTO_USERNAMEMagento user login name.user
MAGENTO_PASSWORDMagento user password.bitnami1
MAGENTO_EMAILMagento user e-mail address.user@example.com
MAGENTO_ENABLE_HTTP_CACHEWhether to enable a HTTP cache server for Magento (i.e. Varnish).no
MAGENTO_HTTP_CACHE_BACKEND_HOSTHTTP cache backend hostname.nil
MAGENTO_HTTP_CACHE_BACKEND_PORT_NUMBERHTTP cache backend port.nil
MAGENTO_HTTP_CACHE_SERVER_HOSTHTTP cache server hostname.nil
MAGENTO_HTTP_CACHE_SERVER_PORT_NUMBERHTTP cache server port.nil
MAGENTO_DATABASE_HOSTDatabase server host.mariadb
MAGENTO_DATABASE_PORT_NUMBERDatabase server port.3306
MAGENTO_DATABASE_NAMEDatabase name.bitnami_magento
MAGENTO_DATABASE_USERDatabase user name.bn_magento
MAGENTO_DATABASE_PASSWORDDatabase user password.nil
MAGENTO_ENABLE_DATABASE_SSLWhether to enable SSL for database connections.no
MAGENTO_VERIFY_DATABASE_SSLWhether to verify the database SSL certificate when SSL is enabled for database connections.yes
MAGENTO_DATABASE_SSL_CERT_FILEPath to the database client certificate file.nil
MAGENTO_DATABASE_SSL_KEY_FILEPath to the database client certificate key file.nil
MAGENTO_DATABASE_SSL_CA_FILEPath to the database server CA bundle file.nil
MAGENTO_SEARCH_ENGINEMagento search engine to use.elasticsearch7
MAGENTO_ELASTICSEARCH_HOSTElasticsearch server host.elasticsearch
MAGENTO_ELASTICSEARCH_PORT_NUMBERElasticsearch server port.9200
MAGENTO_ELASTICSEARCH_USE_HTTPSWhether to use https to connect with Elasticsearch.no
MAGENTO_ELASTICSEARCH_ENABLE_AUTHWhether to enable authentication for connections to the Elasticsearch server.no
MAGENTO_ELASTICSEARCH_USERElasticsearch server user login.nil
MAGENTO_ELASTICSEARCH_PASSWORDElasticsearch server user password.nil

Read-only environment variables

NameDescriptionValue
MAGENTO_BASE_DIRMagento installation directory.${BITNAMI_ROOT_DIR}/magento
MAGENTO_BIN_DIRMagento directory for executable files.${MAGENTO_BASE_DIR}/bin
MAGENTO_CONF_FILEConfiguration file for Magento.${MAGENTO_BASE_DIR}/app/etc/env.php
MAGENTO_VOLUME_DIRMagento directory for mounted configuration files.${BITNAMI_VOLUME_DIR}/magento
PHP_DEFAULT_MAX_EXECUTION_TIMEDefault PHP max execution time.18000
PHP_DEFAULT_MEMORY_LIMITDefault PHP memory limit.1G

When you start the Magento image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. If you want to add a new environment variable:

  • For docker-compose add the variable name and value under the application section in the docker-compose.yml file present in this repository:
magento:
  ...
  environment:
    - MAGENTO_PASSWORD=my_password1234
  ...
  • For manual execution add a --env option with each variable and value:

    docker run -d --name magento -p 80:8080 -p 443:8443 \
      --env MAGENTO_PASSWORD=my_password1234 \
      --network magento-tier \
      --volume /path/to/magento-persistence:/bitnami \
      bitnami/magento:latest
    

Logging

The Bitnami Magento Docker image sends the container logs to stdout. To view the logs:

docker logs magento

Or using Docker Compose:

docker-compose logs magento

You can configure the containers logging driver using the --log-driver option if you wish to consume the container logs differently. In the default configuration docker uses the json-file driver.

Maintenance

Backing up your container

To backup your data, configuration and logs, follow these simple steps:

Step 1: Stop the currently running container

docker stop magento

Or using Docker Compose:

docker-compose stop magento

Step 2: Run the backup command

We need to mount two volumes in a container we will use to create the backup: a directory on your host to store the backup in, and the volumes from the container we just stopped so we can access the data.

docker run --rm -v /path/to/magento-backups:/backups --volumes-from magento busybox \
  cp -a /bitnami/magento /backups/latest
Restoring a backup

Restoring a backup is as simple as mounting the backup as volumes in the containers.

For the MariaDB database container:

 $ docker run -d --name mariadb \
   ...
-  --volume /path/to/mariadb-persistence:/bitnami/mariadb \
+  --volume /path/to/mariadb-backups/latest:/bitnami/mariadb \
   bitnami/mariadb:latest

For the Magento container:

 $ docker run -d --name magento \
   ...
-  --volume /path/to/magento-persistence:/bitnami/magento \
+  --volume /path/to/magento-backups/latest:/bitnami/magento \
   bitnami/magento:latest
Upgrade this image

Bitnami provides up-to-date versions of MariaDB and Magento, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container. We will cover here the upgrade of the Magento application and bundled components (Apache, PHP...). For the MariaDB upgrade see: https://github.com/bitnami/containers/tree/main/bitnami/mariadb#upgrade-this-image

Upgrading the Magento application

Follow this guide to update the Magento version used in your running container image. Note that the below steps will not update any bundled image components such as Apache or PHP, to do this check the next section.

Step 1: Create a backup

Before following any of the below steps, create a backup of your container to avoid possible data loss, in case something goes wrong.

Step 2: Getting Magento authentication keys

In order to properly upgrade Magento, you will need Magento authentication keys that will be used to fetch the Magento updates. To obtain these keys, follow this guide.

Step 3: Preparing the Docker container for the upgrade
  • Enter the container shell as the root user (e.g. docker exec -u root ...).

  • Only if the container is running as root user, disable cron jobs and wait for any pending jobs to complete:

    sed -i 's/^/#/' /etc/cron.d/magento
    
  • Increase the PHP memory_limit to an apropriate value for the upgrade commands to work, such as 2G:

    sed -i 's/memory_limit = .*/memory_limit = 2G/' /opt/bitnami/php/etc/php.ini
    
  • Backup composer.json:

    cp /opt/bitnami/magento/composer.json /opt/bitnami/magento/composer.json.bak
    
Step 4: Update Magento to the desired version
  • Only if the container is running as root user, login as the web server user before executing the below command:

    su daemon -s /bin/bash
    
  • To avoid user access to your Magento site while you are upgrading, enable maintenance mode:

    magento maintenance:enable
    
  • Update your Magento requirement to the new desired version in composer.json. At this point, you will be asked to provide credentials to access repo.magento.com. Enter the authentication keys obtained in Step 1.

    cd /opt/bitnami/magento
    composer require magento/product-community-edition=VERSION --no-update
    

    NOTE: Replace the VERSION placeholder with an appropriate value, i.e.: 2.4.1

Note: the README for this image is longer than the DockerHub length limit of 25000, so has been trimmed. The full README can be found at https://github.com/bitnami/containers/blob/main/bitnami/magento/README.md

Docker Pull Command

docker pull bitnami/magento
Bitnami