Docker enables fast local environments. DDEV simplifies the use of Docker for PHP projects. With your project configuration can shared with others on the team and version-controlled for consistency and easier maintenance.
If you already have Docker, update to the latest version, otherwise, download Docker from https://docs.docker.com/docker-for-mac/install. You will need to login with your Docker ID and password.
Install Docker to your Applications folder as with any other app (perhaps add it to your macOS Dock as well).
The Docker GUI adds a menu bar icon with shortcuts. Use this to update to the latest version of Docker or to quit Docker when you aren't using it.
If you need to uninstall and reinstall Docker you can do that too: Select Preferences, select Reset (bomb icon), select Uninstall.
I always recommend using Homebrew to install and managing CLI tools on a Mac.
It can be used to manage PHP versions and extensions, or to install tools like composer
. As an example, to install wget
on macOS, you would use:
brew install wget
wget --version
I assume you already have Homebrew but take this time to update Homebrew:
brew update && brew upgrade
brew cleanup
brew doctor
This is a good time to update composer as well:
composer self-update
In your Terminal, run this:
docker run --detach --publish=80:80 --name=webserver nginx
Then visit: http://localhost/
It should say “Welcome to nginx!"
At any time, you should be able to run docker container ls
and note the CONTAINER ID
and the IMAGE
name. To stop any container, use its ID, like this:
docker stop e4d9ac3e4e80
You may need to login by typing docker login
(use your username in the CLI, not your email address).
If get a port binding error you might want to clear everything out, like this:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
With Docker working well on your Mac, you are ready to install DDEV!
brew tap drud/ddev
brew install ddev
Here's the online guide, if you get stuck: https://ddev.readthedocs.io/en/stable/#installation
You will need mkcert so please just follow the instructions.
mkcert -install
At this point, you have the basic commands you need to work with Docker and resolve common errors like port binding!
You're ready to start a DDEV project. Let's set BASH variable, by typing this in your Terminal.
export SITE_NAME=mark
echo $SITE_NAME
Navigate to your website project directory.
cd ~/Sites
Use composer create-project
to start a new project.
composer create-project drupal-composer/drupal-project:8.x-dev --stability dev --no-interaction $SITE_NAME
Now cd
into the new directory and run ddev config
ddev config
Accept the default values for Project Name, Docroot Location (web), and Project Type (drupal8).
Then run:
ddev start
You should have a local web address for your project. I suggest installing the Umami demo profile.