how to run Docker VM for Drupal on a Mac

what is Docker?

Docker is a virtual machine that can be used to run your web applications on your computer. The main advantage of using Docker compared to other Virtual machine software is how Docker splits a single machine into sections (Containers) for your applications instead of creating a new machine per application, thus saving room… lots of room.

how to use Docker (Macintosh)

The simplest way to take advantage of Docker is through its native Mac application. All the steps to install are on the same page and very easy to follow. Before installing, please check your system meets all the requirements listed here.

using verified images for a basic server

The simplest way to create a container with everything you need for a Drupal site is to use Docker Compose, which allows you to define the images you want and allow you to start and stop them all with one basic command.

To get started, create a 'docker-compose.yml' file in the root of your application and add the following lines:

version: '2'


    image: mysql:5.7
      - "3306:3306"
      - "./.data/db:/var/lib/mysql"
    restart: always
      MYSQL_DATABASE: drupal
      MYSQL_USER: drupal
      MYSQL_PASSWORD: drupal

      - db
    image: drupal:latest
      - db
      - “8080:80"
    restart: always

You can now build your new docker container:

docker-compose up -d

'-d' Flag stops Docker outputting the containers log in the current window.

access your new site

Go to your new Drupal site: or http://localhost:8080

install your new site

If its installed correctly, you should see the Drupal 8 installation page. Drupal should automatically skip over the ‘Verify requirements’ page if all requirements are met.

You’ve set your MySQL details in your docker-compose file, use these to connect you Drupal site to your MySQL database. If you cannot connect to MySQL on host localhost or Try finding the the host IP using the ifconfig command. Your IP should look something like this: 10.X.X.X.

stop your container

When you're finished updating your application, you can stop the containers by running:

docker-compose stop

other commands

You can find all Docker compose commands on Dockers website or by running the help command in your applications root:

docker-compose --help

using Drupal 7?

To download Drupal 7; Change 'drupal:latest' to 'drupal:7-apache' in your docker-compose.yml file.

If you want to take back control of your web sites and applications then get in touch with miggle to see how we can deliver operational freedom for you in Drupal.