How install drupal + drush + mysql + composer together in docker on macOS

I want to be able to create and run a drupal site locally under macOS (Catalina) inside Docker. I’m totally confused how to get everything I need all together: druapl, drush, mysql, and composer. Different sources seem to give only pieces of the process and are often impenetrable to me.

For example, gives clear instructions to use a Terminal command such as:

docker pull drupal:8.9.2-apache

(That’s a more recent version than the blog uses.)

But then it says the next step is: Create a new Dockerfile and use the new Drupal image drupal:8.9.2-apache in the FROM instruction:

FROM drupal:8.9.2-apache

But where and how does one create that Dockerfile that includes that FROM instruction? Does anything else need to go into that Dockerfile?

Here’s what I’ve already done:

  1. Installed Docker Desktop for Mac (version 23).

  2. Executed docker pull drupal:8.9.2-apache.


  1. Exactly what do I do next?

  2. The remaining instructions in the referenced blog tell how to install composer and drush. But how do I get mysql, which I’ll use for drupal?

There are too many tutorials out there, some of them are outdated, some contain errors. For this reason the place to start should always be the docs of the official image on Dockerhub. For Drupal you find it here. If you scroll down you find an example of a compose file. Yes, it uses Postgres, but you should be able to replace it with MySQL. If you are not sure you what a Dockerfile, the Docker command line and docker-compose are you should go one step back and start to learn the basics.