Deploy secure and flexible docker infrastructure for Magento 2 in a matter of seconds.
Disclaimer: By default, the latest versions of packages are configured, above those recommended by Magento 2
- Install Docker [ Debian ]:
you can use any linux host or Docker Desktop
https://docs.docker.com/
https://docs.docker.com/engine/install/debian/
- Use init.sh script provided to install and configure docker environment:
curl -Lo init.sh https://raw.githubusercontent.com/magenx/Magento-2-docker-configuration/main/init.sh && . init.sh
- Manual commands:
apt update && apt upgrade -y
apt-get -y install ca-certificates software-properties-common screen ipset vim strace rsyslog git apache2-utils
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
- Install docker compose cli:
apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Add alias or use auto completion feature:
echo "alias doco='docker compose'" >> ~/.bash_profile
. ~/.bash_profile
- Create deployment directory:
mkdir /opt/magento && cd /opt/magento
- Clone repo:
git clone https://github.com/magenx/Magento-2-docker-configuration.git .
- To avoid copying default passwords and hacking through open ports - generate new passwords:
https://docs.docker.com/compose/compose-file/compose-file-v3/#secrets
bash passgen.sh
[ ! ] Check all data, adjust your settings, edit your variables
- Run to pull and build images and start containers:
doco build --no-cache
doco up -d
- Watch syslog for errors and issues:
tail -f /var/log/syslog
- To request TLS/SSL certificate with certbot you can run this command [--staging] to test:
doco stop nginx
doco run -p 80:80 --rm certbot certonly \
--email ${ADMIN_EMAIL} --agree-tos --no-eff-email --standalone -d ${DOMAIN} --staging
doco start nginx
change your nginx configuration to uncomment tls/ssl
remove [--staging] flag to reissue live certificate
- To request TLS/SSL certificate with certbot in realtime you can run this command:
doco run --rm certbot certonly \
--email ${ADMIN_EMAIL} --agree-tos --no-eff-email --webroot -w ${WEB_ROOT_PATH} -d ${DOMAIN}
doco restart nginx
- Get random mariadb root password from log:
doco logs mariadb 2>&1 | grep GENERATED
magenx-mariadb | 2021-11-16 08:48:17-05:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: xxxxxxxx
- Stop all services:
doco down
Stopping magenx-cron ... done
Stopping magenx-nginx ... done
Stopping magenx-php ... done
Stopping magenx-opensearch ... done
Stopping magenx-rabbitmq ... done
Stopping magenx-varnish ... done
Stopping magenx-certbot ... done
Stopping magenx-phpmyadmin ... done
Stopping magenx-mariadb ... done
Stopping magenx-redis ... done
- MariaDB - MariaDB Server is a high performing open source relational database, forked from MySQL.
- Nginx - Official build of Nginx.
- PHP - PHP scripting language.
- Varnish - Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as APIs.
- OpenSearch - Opensearch is a powerful open source search and analytics engine that makes data easy to explore.
- Redis x2 - Redis is an open source key-value store that functions as a data structure server.
- RabbitMQ - RabbitMQ is an open source multi-protocol messaging broker.
- PHPMyAdmin - phpMyAdmin - A web interface for MySQL and MariaDB.
- Certbot - Official build of EFF's Certbot tool for obtaining TLS/SSL certificates from Let's Encrypt.
- [Cron]