admin/ March 20, 2017/ Docker, Linux, Magento2/ 3 comments

Install Magento2 on Docker Containers.

Now its time to install the Magento 2.x or Magento1.x as you want. You can put your code, import your database and set URL. Enjoy your Magento instance.

Yes, Now we come to docker. Install docker and docker-compose on your Linux machine enjoy your docker instance with few commands. It is really very easy.

How to install Docker ?

There are the few simple steps to install docker and docker-compose.
Step 1-: Install Docker on Ubuntu Machine

$ sudo apt update
$ sudo apt-get install -y \
    linux-image-extra-$(uname -r) \
$ sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
$ sudo apt install -y git 

Install Docker Compose in Ubuntu Machine.

$ curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose


$ curl -L "$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
$ chmod +x /usr/bin/docker-compose

Step 2-: Open your Terminal or ctrl + alt + t ( Shortcut to open terminal )

$ git clone

$ cd magento2-developer

Step 3-: Git clone the Default Magento2 or copy your code in a html directory.

$ git clone  html


$ git clone -b  html


$ git clone -b 2.1.5  html


$ cp -r /var/www/html $PWD/html

Step 4-: Start the docker container by using below commands.

$ docker-compose up -d

Notes-: Please stop your apache2 or nginx and mysql server. Because we are using port 80 and 3306 in the give docker-compose.yml.

It will pull the required images first time. It will the images like arvindr226/m2, phpmyadmin/phpmyadmin, mysql.
Then it will create containers as configured in the file docker-compose.yml.


Step 5-: Now your docker instance is ready to install or use.
Hit the URL like http://localhost/ or http://serverip/

Step 6-: You need to install composer packages.

$ docker exec -it magento2-developer composer install

You will get the screen like below-:

You need to change the permission of your code directories: app, pub, var like below-:

$ chmod -R 777 html/app/ html/var/ html/pub

Step 7-: Now, we will fill the database credentials. According to my docker-compose.yml.
Host-: magento2_db
Username-: magento2
Password-: gotechnies

Follow the wizards fill the proper credentials here.

Step 8-: Install your magento2 instance.

you will get the success page like below-:

How to connect with phpmyadmin or Mysql via terminal ?

To access the phpmyadmin. Here we have linked the container with mysql container.
Simply use the URL with Port 8080.

Terminal Access:

$ mysql -umagento2 -pgotechnies -h0.0.0.0 

Aditional Step-: Connect the container using ssh.

$ ssh [email protected] -p2222

Use the password-: screencast

Reference URLs-:

Share this Post


  1. Thanks for sharing.

  2. Thanks a lot for this wonderful tutorial!

    After step 6, I got this error

    “Your requirements could not be resolved to an installable set of packages.

    Problem 1
    – The requested PHP extension ext-soap * is missing from your system. Install or enable PHP’s soap extension.

    How can I solve this issue?

    1. install soap php module using below command.

      $ sudo apt-get install php-soap
      $ sudo apt install php7.0-soap
      $ sudo apt install php7.1-soap

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.