You are here

Running Drupal using Docker on OSX

If you're on OSX, you'll have to run docker inside a VM. The official boot2docker works.

Follow the steps: https://docs.docker.com/mac/step_one

Once the docker terminal is open, you can start running containers.

First use docker to start mysql using the official mysql project from https://registry.hub.docker.com/_/mysql/

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

Now start up Drupal. You can use any available tags from https://registry.hub.docker.com/_/drupal/

You'll also need to link up your mysql container "some-mysql" to the new Drupal container. This is all done in one command.

docker run --name some-drupal -p 8080:80 --link some-mysql:mysql -d drupal

You'll need to connect to the mysql server and create a database for Drupal to use.

docker run -it --link some-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
CREATE DATABASE my-drupal-db;

Exit the mysql container back to your boot2docker VM.

If you don't already have it handy, you can find out what your boot2docker IP is painlessly.

boot2docker ip

The Drupal container will be bound to your boot2docker IP at port 8080. It will be the IP reported from the above command. Eg: 192.168.59.103:8080

The Drupal installer should start once you visit the boot2docker IP at the correct port. When you get to the DB configuration screen, you'll need to open up the "Advanced" fieldset and add your mysql container's IP rather than the standard localhost. You can grab this via docker's 'inspect' command.

docker inspect some-mysql | grep IPAddress

That's pretty much it, you should see what you'd expect to see from here on out. You will be able to finish the installer and start using the Drupal application inside a container.

Submitted by brant on Tue, 06/23/2015 - 23:10