bitnami/magento
🛑 DEPRECATED Bitnami container image for Magento
10M+
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.
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.
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.
Looking to use Magento in production? Try VMware Tanzu Application Catalog, the commercial edition of the Bitnami catalog.
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.
Dockerfile
linksLearn 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.
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 .
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.
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/
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:
docker exec -it magento /bin/bash
su daemon -s /bin/bash
cd /bitnami/magento
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
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.
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.
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
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
When the container is executed for the first time, it will execute the files with extensions .sh
located at /docker-entrypoint-initdb.d
.
Customizable environment variables
Name | Description | Default Value |
---|---|---|
MAGENTO_DATA_TO_PERSIST | Files to persist relative to the Magento installation directory. To provide multiple values, separate them with a whitespace. | $MAGENTO_BASE_DIR |
MAGENTO_HOST | Magento host domain or IP address. | localhost |
MAGENTO_ENABLE_HTTPS | Whether to enable SSL to access the Magento store. | no |
MAGENTO_ENABLE_ADMIN_HTTPS | Whether to use SSL to access the Magento administration panel. | no |
MAGENTO_EXTERNAL_HTTP_PORT_NUMBER | Port to access Magento from outside of the instance using HTTP. | 80 |
MAGENTO_EXTERNAL_HTTPS_PORT_NUMBER | Port to access Magento from outside of the instance using HTTPS. | 443 |
MAGENTO_FIRST_NAME | Magento user first name. | FirstName |
MAGENTO_LAST_NAME | Magento user last name. | LastName |
MAGENTO_MODE | Magento mode. | default |
MAGENTO_EXTRA_INSTALL_ARGS | Extra flags to append to the Magento 'setup:install' command call. | nil |
MAGENTO_ADMIN_URL_PREFIX | URL prefix to access the Magento administration panel. | admin |
MAGENTO_DEPLOY_STATIC_CONTENT | Whether to deploy Magento static content during the initialization, to optimize initial page load time. | no |
MAGENTO_KEEP_STATIC | Whether to keep the content of 'pub/static' folder during the initialization. | no |
MAGENTO_SKIP_REINDEX | Whether to skip Magento re-index during the initialization. | no |
MAGENTO_SKIP_BOOTSTRAP | Whether to perform initial bootstrapping for the application. | no |
MAGENTO_USERNAME | Magento user login name. | user |
MAGENTO_PASSWORD | Magento user password. | bitnami1 |
MAGENTO_EMAIL | Magento user e-mail address. | user@example.com |
MAGENTO_ENABLE_HTTP_CACHE | Whether to enable a HTTP cache server for Magento (i.e. Varnish). | no |
MAGENTO_HTTP_CACHE_BACKEND_HOST | HTTP cache backend hostname. | nil |
MAGENTO_HTTP_CACHE_BACKEND_PORT_NUMBER | HTTP cache backend port. | nil |
MAGENTO_HTTP_CACHE_SERVER_HOST | HTTP cache server hostname. | nil |
MAGENTO_HTTP_CACHE_SERVER_PORT_NUMBER | HTTP cache server port. | nil |
MAGENTO_DATABASE_HOST | Database server host. | mariadb |
MAGENTO_DATABASE_PORT_NUMBER | Database server port. | 3306 |
MAGENTO_DATABASE_NAME | Database name. | bitnami_magento |
MAGENTO_DATABASE_USER | Database user name. | bn_magento |
MAGENTO_DATABASE_PASSWORD | Database user password. | nil |
MAGENTO_ENABLE_DATABASE_SSL | Whether to enable SSL for database connections. | no |
MAGENTO_VERIFY_DATABASE_SSL | Whether to verify the database SSL certificate when SSL is enabled for database connections. | yes |
MAGENTO_DATABASE_SSL_CERT_FILE | Path to the database client certificate file. | nil |
MAGENTO_DATABASE_SSL_KEY_FILE | Path to the database client certificate key file. | nil |
MAGENTO_DATABASE_SSL_CA_FILE | Path to the database server CA bundle file. | nil |
MAGENTO_SEARCH_ENGINE | Magento search engine to use. | elasticsearch7 |
MAGENTO_ELASTICSEARCH_HOST | Elasticsearch server host. | elasticsearch |
MAGENTO_ELASTICSEARCH_PORT_NUMBER | Elasticsearch server port. | 9200 |
MAGENTO_ELASTICSEARCH_USE_HTTPS | Whether to use https to connect with Elasticsearch. | no |
MAGENTO_ELASTICSEARCH_ENABLE_AUTH | Whether to enable authentication for connections to the Elasticsearch server. | no |
MAGENTO_ELASTICSEARCH_USER | Elasticsearch server user login. | nil |
MAGENTO_ELASTICSEARCH_PASSWORD | Elasticsearch server user password. | nil |
Read-only environment variables
Name | Description | Value |
---|---|---|
MAGENTO_BASE_DIR | Magento installation directory. | ${BITNAMI_ROOT_DIR}/magento |
MAGENTO_BIN_DIR | Magento directory for executable files. | ${MAGENTO_BASE_DIR}/bin |
MAGENTO_CONF_FILE | Configuration file for Magento. | ${MAGENTO_BASE_DIR}/app/etc/env.php |
MAGENTO_VOLUME_DIR | Magento directory for mounted configuration files. | ${BITNAMI_VOLUME_DIR}/magento |
PHP_DEFAULT_MAX_EXECUTION_TIME | Default PHP max execution time. | 18000 |
PHP_DEFAULT_MEMORY_LIMIT | Default 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:
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
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.
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 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
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.
Before following any of the below steps, create a backup of your container to avoid possible data loss, in case something goes wrong.
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.
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
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