Install Magento2 using docker

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) \
    linux-image-extra-virtual
$ sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
$ sudo apt install -y docker.io git 

Install Docker Compose in Ubuntu Machine.

$ curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose

or

$ curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(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 https://github.com/arvindr226/magento2-developer

$ cd magento2-developer

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

$ git clone https://github.com/magento/magento2.git  html

or

$ git clone -b  https://github.com/magento/magento2.git  html

example-:

$ git clone -b 2.1.5 https://github.com/magento/magento2.git  html

or

$ 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.

Output-:

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.
http://localhost:8080
or
http://serverip: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-:

https://docs.docker.com/
https://magento.com/
https://github.com/arvindr226/
https://docs.docker.com/compose/

3 Comments

  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
      or
      $ sudo apt install php7.0-soap
      or
      $ sudo apt install php7.1-soap

Leave a Reply