Docker is a software platform based on containers. Each container is effectively a piece of software whereby the code between them can be shared – this can be very handy if we’re running two different Magento stores on a single server, for example.

The Docker LAMP image is a Docker container that’s been pre-configured to run as a LAMP server.

Here is a simple tutorial to get you started.

First, download and install Docker.

Once you have that out of the way, you’ll first need to delete the default machine, and replace it with one that has a bit more RAM. You shouldn’t allocate more than half of your total RAM to the machine. Since I have 8GB of RAM, I’ll allocate 4GB to Docker, so I still have a bit for my host machine.

Remove the existing machine:

docker-machine rm default

Replace it with a new one:

docker-machine create -d virtualbox --virtualbox-memory "4096" default

You can replace `default` with whatever you like. With your new machine set up,  clone the git repo to your local machine and cd into the directory where these files are located. Docker will start you at your home by default, so for me it’s just

cd Documents/docker-lamp

After you’ve confirmed that you don’t have XAMPP or any local apache/mysql instances running, you can fire up the Docker machine with this command:

docker-compose up -d

This will take some time because Docker will have to fetch and configure the image. Once this command completes, you can run the following command to get the ip address for the machine, allowing you to connect to it in your browser and via MySQL Workbench:

docker-machine ip default

Once you have your Docker machine running, you can place your files in the public_html folder, which will copy them to the /var/www/html folder of the Docker machine. To get shell access to your machine, just run the following command:

docker exec -it dockerlamp_app_1 /bin/bash

You will now be in a bash shell as the root user for the Docker machine. Anything that you put into the docker-lamp/public_html folder will automatically be copied into the /var/www/html folder of the Docker machine, even while it is running.

And you’re done! From here you can treat it like a standard local setup. Create a database, pull down a repository and place it in the public_html folder, and you’re set.

Commands Cheat Sheet

 

composer:
docker exec -it dockerlamp_app_1 composer

interactive bash shell:
docker exec -it dockerlamp_app_1 /bin/bash

magerun:
docker exec -it dockerlamp_app_1 magerun

mysql:
docker exec -it dockerlamp_app_1 mysql

modman:
docker exec -it dockerlamp_app_1 modman

© 2017 Accolade Ltd. All Rights Reserved.