Sign inSign up

magebr/magento

By magebr

•Updated about 8 years ago

Run your Magento locally using Docker.

Image
1

245

magebr/magento repository overview

⁠magebr-docker

N|Solid

This docker was created so you can run your code locally. This only works with Magento 1 (CE and EE). Follow the steps below to get it all set up!

⁠Requirements
⁠Installation

Any of the steps below can be changed to your folder. First we need to create a folder where we will clone your repo:

mkdir -p ~/Sites/magento/my-repo/

Next step is to clone this repo:

git clone [email protected]:CajuCLC/docker-magento.git ~/Sites/magento/magebr-docker-magento

We also need to clone your repo to your folder, make sure you change it here:

git clone [email protected]:MYUSER/my-repo.git ~/Sites/magento/my-repo

Now the easy step, start the containers!

cd ~/Sites/magento/magebr-docker-magento
docker-compose up -d

When you start for the first time it might take some time to download and extract the image. While you wait you can open a new terminal and a domain for your local environment. As other commands, you can change to whatever you would like.

sudo -- sh -c "echo 127.0.0.1 local.mymagento.com >> /etc/hosts"

We are almost done, we need to import the database locally. You must have some MySQL client installed. First you need to get the MySQL port:

docker ps

It will show something like this:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES
d1ab04ca0b04        mysql:5.6           "docker-entrypoint.s…"   12 seconds ago      Up 7 seconds        0.0.0.0:32812->3306/tcp                    magebr-magento-db
790cc90177fe        redis:3.2           "docker-entrypoint.s…"   12 seconds ago      Up 6 seconds        0.0.0.0:32810->6379/tcp                    magebr-magento-session
e29c36cdbd8f        redis:3.2           "docker-entrypoint.s…"   12 seconds ago      Up 8 seconds        0.0.0.0:32811->6379/tcp                    magebr-magento-fpc
93743f8a890f        cajuclc/magento     "docker-php-entrypoi…"   12 seconds ago      Up 9 seconds        0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   magebr-magento-web
43951fdab672        redis:3.2           "docker-entrypoint.s…"   12 seconds ago      Up 10 seconds       0.0.0.0:32809->6379/tcp                    magebr-magento-cache

In this example MySQL is on port 32812, to import the database run the command below (make sure you move the database file to the same folder):

mysql -u root -proot -P [PORT] -h 127.0.0.1 magento < ~/Sites/magento/database/database.sql

The last step is to configure the local.xml file. We offer two options, one without Redis cache and session and one with them configured. They are both inside resources folder (https://github.com/CajuCLC/docker-magento/tree/master/resources⁠)

With Redis: default.local.redis.xml
Without Redis: default.local.xml

Just pick one and copy to your repo folder, command will look like this:

  • With Redis
cp ~/Sites/magento/magebr-docker-magento/resources/default.local.redis.xml ~/Sites/magento/my-repo/app/etc/local.xml
  • Without Redis
cp ~/Sites/magento/magebr-docker-magento/resources/default.local.xml ~/Sites/magento/my-repo/app/etc/local.xml

That should be it. Have fun coding locally!

Tag summary

Content type

Image

Digest

Size

190.7 MB

Last updated

about 8 years ago

docker pull magebr/magento