Manual Setup Same result as the one-liner above. Just replace magento2.test references with the hostname that you wish to use.
New Projects
curl -s https://raw.githubusercontent.com/zaheercena/docker-magento/master/lib/template | bash
bin/download 2.4.1
or if you'd rather install with Composer, run:
rm -rf src
composer create-project --repository=https://repo.magento.com/ --ignore-platform-reqs --prefer-dist magento/project-community-edition=2.4.1 src
composer create-project --repository=https://repo.magento.com/ --ignore-platform-reqs --prefer-dist magento/project-enterprise-edition=2.4.1 src
echo "127.0.0.1 ::1 cozmot-m2.test" | sudo tee -a /etc/hosts
bin/setup magento2.test
open https://magento2.test Existing Projects
curl -s https://raw.githubusercontent.com/zaheercena/docker-magento/master/lib/template | bash
cp -R ~/Sites/existing src
or: git clone git@github.com:myrepo.git src
echo "127.0.0.1 ::1 yoursite.test" | sudo tee -a /etc/hosts
docker-compose up -d rm -rf src/vendor bin/copytocontainer --all ## Initial copy will take a few minutes...
bin/composer install bin/copyfromcontainer vendor
bin/mysql < backups/magento.sql
vi src/app/etc/env.php
bin/magento app:config:import
bin/magento config:set web/secure/base_url https://yoursite.test/ bin/magento config:set web/unsecure/base_url https://yoursite.test/
bin/restart
open https://cozmot-m2.test For more details on how everything works, see the extended setup readme.
Updates To update your project to the latest version of docker-magento, run:
bin/update We recommend keeping your docker config files in version control, so you can monitor the changes to files after updates. After reviewing the code updates and ensuring they updated as intended, run bin/restart to restart your containers to have the new configuration take effect.
It is recommended to keep your root docker config files in one repository, and your Magento code setup in another. This ensures the Magento base path lives at the top of one specific repository, which makes automated build pipelines and deployments easy to manage, and maintains compatibility with projects such as Magento Cloud.
Custom CLI Commands bin/bash: Drop into the bash prompt of your Docker container. The phpfpm container should be mainly used to access the filesystem within Docker. bin/cache-clean: Access the cache-clean CLI. Note the watcher is automatically started at startup in bin/start. Ex. bin/cache-clean config full_page bin/cli: Run any CLI command without going into the bash prompt. Ex. bin/cli ls bin/clinotty: Run any CLI command with no TTY. Ex. bin/clinotty chmod u+x bin/magento bin/cliq: The same as bin/cli, but pipes all output to /dev/null. Useful for a quiet CLI, or implementing long-running processes. bin/composer: Run the composer binary. Ex. bin/composer install bin/copyfromcontainer: Copy folders or files from container to host. Ex. bin/copyfromcontainer vendor bin/copytocontainer: Copy folders or files from host to container. Ex. bin/copytocontainer --all bin/dev-urn-catalog-generate: Generate URN's for PHPStorm and remap paths to local host. Restart PHPStorm after running this command. bin/devconsole: Alias for bin/n98-magerun2 dev:console bin/devtools-cli-check: Check & install the CLI devtools if missing from system. bin/download: Download & extract specific Magento version to the src directory. If the archive download fails, it will attempt to download with Composer. Ex. bin/download 2.4.1 bin/fixowns: This will fix filesystem ownerships within the container. bin/fixperms: This will fix filesystem permissions within the container. bin/grunt: Run the grunt binary. Ex. bin/grunt exec bin/magento: Run the Magento CLI. Ex: bin/magento cache:flush bin/mysql: Run the MySQL CLI with database config from env/db.env. Ex. bin/mysql -e "EXPLAIN core_config_data" orbin/mysql < backups/magento.sql bin/mysqldump: Backup the Magento database. Ex. bin/mysqldump > backups/magento.sql bin/n98-magerun2: Access the n98-magerun2 CLI. Ex: bin/n98-magerun2 dev:console bin/node: Run the node binary. Ex. bin/node --version bin/npm: Run the npm binary. Ex. bin/npm install bin/pwa-studio: (BETA) Start the PWA Studio server. Note that Chrome will throw SSL cert errors and not allow you to view the site, but Firefox will. bin/redis: Run a command from the redis container. Ex. bin/redis redis-cli monitor bin/remove: Remove all containers. bin/removeall: Remove all containers, networks, volumes, and images. bin/removevolumes: Remove all volumes. bin/restart: Stop and then start all containers. bin/root: Run any CLI command as root without going into the bash prompt. Ex bin/root apt-get install nano bin/rootnotty: Run any CLI command as root with no TTY. Ex bin/rootnotty chown -R app:app /var/www/html bin/setup: Run the Magento setup process to install Magento from the source code, with optional domain name. Defaults to magento2.test. Ex. bin/setup magento2.test bin/setup-grunt: Install and configure Grunt JavaScript task runner to compile .less files bin/setup-pwa-studio: (BETA) Install PWA Studio (requires NodeJS and Yarn to be installed on the host machine). Pass in your base site domain, otherwise the default master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud will be used. Ex: bin/setup-pwa-studio magento2.test bin/setup-ssl: Generate an SSL certificate for one or more domains. Ex. bin/setup-ssl magento2.test magento3.test bin/setup-ssl-ca: Generate a certificate authority and copy it to the host. bin/start: Start all containers, good practice to use this instead of docker-compose up -d, as it may contain additional helpers. bin/status: Check the container status. bin/stop: Stop all containers. bin/update: Update your project to the most recent version of docker-magento. bin/xdebug: Disable or enable Xdebug. Accepts params disable (default) or enable. Ex. bin/xdebug enable