Installing Magento 2 in 5 minutes with Docker
- Hadrien Collongues
- December 23, 2014
Today we are featuring Hadrien from Occitech with a post on installing Magento 2 in 5 minutes with Docker. The post originally appeared on the Occitech blog and has been translated to English by his colleague Frank.
Magento 2 0.42.0-beta1 is available since a few days. In order to take a look at it right away, let’s walk through the process of installing it in 5 minutes sharp thanks to Docker.
The Docker files provided will give you access to either a read-only “discovery mode” instance of Magento 2 to have a play with it, or a “developer mode” which is a Magento 2 development environment you can experiment with.
Walking through the installation and setup process of Docker is outside the scope of this article. This guide assumes you already have a running and functional Docker-environment set up.
docker run --name magento2_db -d -e MYSQL_ROOT_PASSWORD="rootpassword" -e MYSQL_DATABASE="magento2" -e MYSQL_USER="user" -e MYSQL_PASSWORD="password" mysql docker run --name magento2_web -d -p 80 --link=magento2_db:db chadrien/magento2:0.42.0-beta1 docker port magento2_web
That’s it. Above commands are all that is needed to get the Docker processes set up. Take the port that the last command returned, go to http://127.0.0.1:PORT in your favorite browser and start installing Magento 2.
When asked for database information, set the host to db. The MySQL database and credentials can be found in the command above.
If you stumble upon the following error message: Cannot determine required PHP extensions: Missing key ‘platform-dev’ in ‘composer.lock’ file, click on “Try Again” until “Next” is available. Then, at the final step, another message will warn you about an error, don’t pay attention to it; it’s a var_dump still present in the Magento 2 code base.
Start with creating a new Magento 2 project via Composer:
composer create-project -n magento/product-community-edition magento2 0.42.0-beta1 cd magento2
The fig.yml YAML configuration file for fig can be found below. Don’t forget to change the passwords:
web: image: chadrien/magento2:5.5-apache links: - db ports: - 80 volumes: - ".:/var/www" db: image: mysql environment: MYSQL_ROOT_PASSWORD: rootpassword MYSQL_DATABASE: magento2 MYSQL_USER: user MYSQL_PASSWORD: password
Up next is starting the containers:
fig up -d fig port web 80
Copy the port returned by the last command and navigate to http://127.0.0.1:PORT – if everything went correctly you should be greeted by the Magento 2 setup wizard.
Again, when asked for database information, set the host to db and refer to the MySQL credentials you supplied earlier. As you can locally navigate to the source code, you can simply start coding and the Docker environment will reflect those changes.
And voilà! Hopefully by sharing this you will be able to get your hands on Magento 2 using Docker.
- December 21, 2022