Docker Community Forums

Share and learn in the Docker community.

Docker/Mac/Magento MySQL root password

I am using the following container:

How do I determine the MySQL root password?

Automated Setup (New Project)
Run this automated one-liner from the directory you want to install your project.

No sample data
curl -s | bash -s – magento2.test 2.4.0
With sample data
curl -s | bash -s – magento2.test with-samples-2.4.0
The magento2.test above defines the hostname to use, and the 2.4.0 defines the Magento version to install. Note that since we need a write to /etc/hosts for DNS resolution, you will be prompted for your system password during setup.

Prefix the version with with-samples- if you would like to automatically install sample data along with Magento.

After the one-liner above completes running, you should be able to access your site at https://magento2.test.

Manual Setup
Same result as the one-liner above. Just replace magento2.test references with the hostname that you wish to use.

New Projects

Download the Docker Compose template:

curl -s | bash

Download the version of Magento you want to use with:

bin/download 2.4.0

or if you’d rather install with Composer, run:


rm -rf src

composer create-project --repository= --ignore-platform-reqs magento/project-community-edition=2.4.0 src


rm -rf src

composer create-project --repository= --ignore-platform-reqs magento/project-enterprise-edition=2.4.0 src

Create a DNS host entry for the site:

echo “ ::1 magento2.test” | sudo tee -a /etc/hosts

Run the setup installer for Magento:

bin/setup magento2.test

open https://magento2.test
Existing Projects

Download the Docker Compose template:

curl -s | bash

Remove existing src directory:

rm -rf src

Replace with existing source code of your existing Magento instance:

cp -R ~/Sites/existing src

or: git clone src

Create a DNS host entry for the site:

echo “ ::1 yoursite.test” | sudo tee -a /etc/hosts

Start some containers, copy files ot them and then restart the containers:

docker-compose up -d
rm -rf src/vendor
bin/copytocontainer --all ## Initial copy will take a few minutes…

Install composer dependencies, then copy artifacts back to the host (for debugging purposes):

bin/composer install
bin/copyfromcontainer vendor

Import existing database:

bin/clinotty mysql -hdb -umagento -pmagento magento < existing/magento.sql

Update database connection details to use the above Docker MySQL credentials:

Also note: creds for the MySQL server are defined at startup from env/db.env

vi src/app/etc/env.php

Import app-specific environment settings:

bin/magento app:config:import

Set base URLs to local environment URL (if not defined in env.php file):

bin/magento config:set web/secure/base_url https://yoursite.test/
bin/magento config:set web/unsecure/base_url https://yoursite.test/


open https://magento2.test
For more details on how everything works, see the extended setup readme.