Skip to main content

Running Docker

Dangerous word... I'm assuming that Docker is installed.  Don't know how to check?  Using Terminal (I prefer iTerm2), run the following command

docker -D info


The set-up

Go to your project directory, and create a docker folder and a “docker-compose.yml” file:

cd /Users/{your_name}/Sites/{your_directory}
mkdir docker
cd docker
vim docker-compose.yml

Copy following code and add it in to the docker-compse.yml file:

version: "3"
    image: nginx:latest
      - "80:80"
      - php
      - database
      - ../src:/var/www/html

    image: php:8.1-fpm
       - "9000:9000"
      - ../src:/var/www/html

    image: mariadb:latest
      - MYSQL_USER=dbuser
      - MYSQL_PASSWORD=root
      - MYSQL_DATABASE=proxy
      - "3306:3306"
      - "/Users/{your_name}/Sites/web-proxy:/var/lib/mysql"


Adjust the following variables from the above command:

MySQL root password: root
Database name: proxy
MySQL user: dbuser
MySQL password: root


There are now three containers:

  • Web container for Nginx latest version, with mapping port 80:80 (the post can be changed to another one if your 80 is used, 84:80, 8083:80 are examples).  If you have issues with the port being already in use, then errors like below will come up.
  • PHP container for the php with the FastCGI Process Manager (FPM).
  • Database container for MariaDB latest version, it’s required to specify MySQL environment variable.


Error bind: address already in use

When attempting the above command did you receive the following error?

docker: Error response from daemon: Ports are not available: listen tcp bind: address already in use.


You can try port 8080.

Error: port already allocated

docker: Error response from daemon: driver failed programming external connectivity on endpoint drupal9 ({HASH}): Bind for failed: port is already allocated.


You can try port 8083.

Success!  You will need to play around here to get a free port.  Or you can query the ports for their status.


Installing Drupal 9.x

To install Drupal, use the following command

composer create-project drupal-composer/drupal-project:9.x-dev {some-dir} --no-interaction

Change {some-dir} to the directory that you want to install.  If you want to install on the directory that you are currently in, use ./

composer create-project drupal-composer/drupal-project:9.x-dev ./ --no-interaction


Related articles