- Running Magento 2 project really fast on your machine.
- Just a few steps to setup.
- No extra step to deploy code from host to container.
- Easy to modify PHP, MySQL, and Nginx configurations.
- Works on Linux, macOS, and Windows.
- php:7.2-fpm
- mysql:5.7
- nginx:1.19
All OS: Install Git
Linux: Install Docker and Docker-compose.
MacOS: Install Docker and Docker-compose.
Windows: Install Docker and Docker-compose.
git clone https://github.com/jaredchu/Magento2-Docker-Development.git [project_name]
cd [project_name]
docker-compose up -d
docker exec -it app bash -c "rm .gitkeep && composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.3 . --prefer-dist --no-interaction --dev"
docker-compose down
docker-compose up -d
You can now start to install your new Magento 2 site via Web Setup Wizard (will be removed in Magento 2.4) or Command Line (recommended).
git clone https://github.com/jaredchu/Magento2-Docker-Development.git [project_name]
cd [project_name]
docker-compose up -d
docker exec -i db mysql -uroot -ppassword magento2 < your-database.sql
'db' => [
'table_prefix' => '',
'connection' => [
'default' => [
'host' => 'db',
'dbname' => 'm2db',
'username' => 'm2user',
'password' => 'm2pw',
'active' => '1',
'driver_options' => [
]
]
]
],
Enter the app
container TTY (to run any command without docker exec -i app
prefix).
docker exec -it app bash
Run the composer installation:
composer install
Check magento command is working or not:
bin/magento --help
127.0.0.1 magento2.local
::1 magento2.local
docker exec -i app bin/magento config:set web/unsecure/base_url http://magento2.local/
docker exec -i app bin/magento config:set web/unsecure/base_link_url http://magento2.local/
docker exec -i app bin/magento config:set web/secure/base_url https://magento2.local/
docker exec -i app bin/magento config:set web/secure/base_link_url https://magento2.local/
9. All done! Visit your [local_domain_name] (http://magento2.local for example) on your browser.
Restart containers (required when you want to apply the changes after modify .env
or docker-composer.yml
):
docker-compose down
docker-compose up -d
Modify .env
, replace RESTART_CONDITION=no
with RESTART_CONDITION=always
.
docker exec -i app bin/magento [parameters]
or
docker exec -it app bash
bin/magento [parameters]
All the common variables are in .env
.
src
- your project root directory that containscomposer.json
andapp
folder.m2dd/local.ini
- PHP configuration file.m2dd/my.cnf
- MySQL configuration file.m2dd/auth.json
- Composer basic auth file.m2dd/conf.d/
- Contains nginx configuration files.m2dd/ssl/
- Contains SSL certs.m2dd/crontabs/root
- Crontab for root user.m2dd/crontabs/www
- Crontab for www user.
Feel free for submitting pull requests to this project.
This project is using SemVer for versioning. For the versions available, see the tags on this repository.
- Jared Chu - Initial work - About Jared
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.