Skip to content

Install Magento

Maksym Zaporozhets edited this page Apr 6, 2026 · 6 revisions

magento:setup

Generate Docker composition from the selected template and install Magento.

Supported Magento versions:

  • 2.3.7
  • 2.4.2
  • 2.4.3
  • 2.4.4-pX (all patches except the first 2.4.4 release)
  • 2.4.5 and above

The tool includes templates for older Magento versions if you need Docker for them, but those versions are not installable anymore. Composer is unable to pull packages for those versions, and Magento installation fails.

Description

This command deploys clean Magento instance of the selected version.

Magento will be configured to use Varnish and Elasticsearch if they are present in the composition.

Magento will not be configured to use Redis! Need to implement this if possible.

Usage

Example usage:

php bin/dockerizer magento:setup <version>

You can enter all required parameters in the interactive mode. Passing all parameters as command options is also possible and works better for automation.

Advanced usage with parameters:

php bin/dockerizer magento:setup 2.4.4 -f \
    --domains='my-magento-project.local www.my-magento-project.local' \
    --template=magento_2.4.4_nginx_varnish_apache \
    --required-services='php_8_1_apache,mariadb_10_4_persistent,elasticsearch_7_16_3' \
    --optional-services=redis_6_2 \
    --with-environment=prod

Note that Magento is running in the production mode, e.g. without dev tools. This is preferable for QA, CI/CD, etc. Developers should restart the composition in the developer mode to enable dev tools:

cd ./.dockerizer/my-magento-project.local-prod/
docker-compose -f docker-compose.yaml -f docker-compose-dev-tools.yaml up -d --force-recreate

Command arguments and options

  • magento-version (first argument): Magento version to install (2.4.6, 2.3.7-p3, etc.)

You can pass any additional options from composition:build-from-template to this command.

Supported software

Supported Magento versions: 2.0.2+ (yes, that old versions work well).

Every template includes software versions according to the Magento system requirements and Release Notes. We highly recommend selecting the services and software versions that will match your server. If the application server has different software versions than listed in the template then, most likely, you should review and change the server software to guarantee Magento stability. You can thought edit the composition after it is generated.

Magento is configured to use the following services if available:

  • Varnish if any container containing varnish is available;
  • ElasticSearch if any container containing elasticsearch is available;

IMPORTANT!

Redis is not configured automatically. RabbitMQ: to be implemented. Your pull requests are appreciated!

Currently supported web server configurations are:

  • Apache
  • Nginx + Varnish + Apache

Magento installation parameters and settings

Magento installation command:

php bin/magento setup:install --admin-firstname='Magento' --admin-lastname='Administrator' \
    --admin-email='email@example.com' --admin-user='development' --admin-password=$escapedAdminPassword \
    --base-url=$baseUrl  --base-url-secure=$baseUrl \
    --db-name=$dbName --db-user='$dbUser' --db-password=$dbPassword \
    --db-prefix=$tablePrefix --db-host=mysql \
    --use-rewrites=1 --use-secure=1 --use-secure-admin=1 \
    --session-save=files --language=en_US --sales-order-increment-prefix='ORD$' \
    --currency=USD --timezone=America/Chicago --cleanup-database

You will get:

  • All website-related files stored to ${DOCKERIZER_PROJECTS_ROOT_DIR}<domain>/
  • Docker composition up and running (without dev tools)
  • docker-compose files and mounted files in the ./.dockerizer/my-magento-project.local/ directory of the project
  • Magento 2 installed without Sample Data (can be installed from inside the container if needed). Web root and respective configurations are set to the ./pub/ folder
  • Self-signed SSL certificate (thanks to mkcert)
  • Traefik reverse-proxy automatically configured to serve this container and handle SSL certificate
  • Domain(s) added to your /etc/hosts if not there yet (this is why you may want to grant write permission on the /etc/hosts)
  • Admin Panel path is displayed after installing Magento
  • Admin Panel login/password are: development/q1w2e3r4 (custom passwords will be added soon). We recommend changing it to the more strict one.
  • Magento is configured to use Varnish and Elasticsearch. Redis is not configured automatically!

If the SSL certificate is not valid in Chrome/Firefox when you first run the app URL then run the following command and restart the browser:

mkcert -install

By default, two docker-compose files are generated:

  • docker-compose.yaml: basic configuration that reflects production environment and can be used in the build environment
  • docker-compose-prod.yaml: development settings and tools for production environment (another PHP container with xDebug, phpMyAdmin, etc.)

Parameters --elasticsearch-host and --search-engine are added depending on the selected services and Magento version.

Post-installation configurations are:

  • catalog/search/elasticsearch{$elasticsearchMajorVersion}_server_hostname": elasticsearch (Magento < 2.4.0)
  • catalog/search/engine: elasticsearch{$elasticsearchMajorVersion} (Magento < 2.4.0)
  • web/unsecure/base_static_url: http://$mainDomain/static/ (Magento < 2.4.2)
  • web/unsecure/base_media_url: http://$mainDomain/media/ (Magento < 2.4.2)
  • web/secure/base_static_url: https://$mainDomain/static/ (Magento < 2.4.2)
  • web/secure/base_media_url: https://$mainDomain/media/ (Magento < 2.4.2)
  • dev/static/sign: 1
  • dev/js/move_script_to_bottom: 1
  • dev/css/use_css_critical_path: 1
  • system/full_page_cache/caching_application: 2
  • system/full_page_cache/varnish/access_list: localhost,php
  • system/full_page_cache/varnish/backend_host: php
  • system/full_page_cache/varnish/backend_port: 80
  • system/full_page_cache/varnish/grace_period: 300

Additionally, setup:config:set --http-cache-hosts= is set to configure app/etc/env.php with Varnish host and port: varnish-cache:80 or varnish-cache:6081 (Varnish 4 only).

Further working with containers

Any operation like running Composer, PHP scripts or Magento commands, etc. MUST be performed only inside the container. In the same way, you must use MySQL client or mysqldump inside the MySQL container.

See an article about Bash aliases that will make your development easier and bring fun to it!

Required environment variables

See composition:build-from-template

Called from other commands

Executes other commands

Clone this wiki locally