Since when I start to work with Docker I had some challenges to adjust for to be a better environment to develop and to be replicable with my team that works with multiple platforms like MacOS, Windows and Linux. I’m trying to change the process for to be more practical and faster in every update, I’m open to suggestion and waiting for your Pull-Request.
This environment contain Apache 2.4 + PHP 7.0.14 + OPCache + MariaDB + Magerun + DevAlias. I have chosen don’t use Varnish and Redis, and my benchmark tests were positives when I compared.
You can find this image utilized in Docker Hub and on Github.
1. Copy and run this command below.
There is a folder in this project calling ./magento2, this folder is the folder /var/www/html/ inside your container, is the folder that you will work on.
git clone https://github.com/clean-docker/Magento2.git m2-docker && cd m2-docker && docker-compose up -d ; docker ps
2. Accessing you Docker.
To access in your browser you can use http://localhost ( I recommend change your /etc/hosts ).
docker exec -ti m2docker_apache_1 bash
3. Installing Magento 2 last version.
Run this command below, so you can access this URL http://localhost/magento2/, is required to use your Public Key and Private Key.
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
4. How to know your MySQL IP.
To install the Magento 2 you will need of the MySQL IP, so run this command below out of your Docker Container to see the IP.
docker inspect m2docker_db_1 | grep IPAddress
Now you know the IP if you want to access the MySQL in your terminal run this command below changing the IP for yours.
mysql -u root -proot -h 0.0.0.0 -P 3300
I hope that this easy tutorial has helped you.