How to setup Docker Image for Magento 2 on Mac Book?

The question:

I want to setup Docker for Magento 2.

I have gone through number of links but didn’t find the solution yet. Can somebody share useful links to do this.


The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Here is how I figured it out:

Step 1. Install Docker

Step 2. Clone Docker Image for Magento 2


or or you can use any other reliable Image.

Step 3. I am considering 1st link for image here. Now from terminal go to the folder YourlocalFolderName/docker-magento2 like

cd YourlocalFolderName/docker-magento2

and run:

docker-compose up -d

Now go to your web container by this command:

docker exec -u 0 -it docker-magento2_web_1 /bin/bash



Step 4. Now run:


Now type same url in your browser as in env file. Thats it.

If you want to install sample data just run:


Push vote up if it was useful for you, so that it may ease the coming readers.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment