Using Docker Nginx, PHP, MySQL on Mac

I’m just starting to get my head around docker and want to use it for a project.

I have followed and have NGINX running fine and can see the NGINX landing page.

  • Access Docker volume Mountpoint with Docker for Mac
  • “Remove” a VOLUME in a Dockerfile
  • Docker build on apt-get update fails
  • A particular image is not getting pulled from Docker Hub - jwilder/nginx-proxy
  • PHPStorm debug application deployed using docker inside vagrant
  • How to start a docker container when windows boots
  • Do I need to install php-fpm and mySQL within my container since my container is only NGINX at this stage?

    How do I configure my project on a custom domain e.g. Do I need to edit an entry in /etc/hosts for and then listen for that URL in an NGINX config?

    Lastly do I need a dockerfile? I already have my container up and my understanding is a dockerfile is only for defining your container?

    An example of a dockerfile for NGINX, PHP and mySQL would be helpful to look at as well.


  • docker-compose volume on node_modules but is empty
  • I can't seem to get my local shared MySQL data volume to persist on Docker for Windows
  • Docker: MySQL refuses host IP unless I restart it manually
  • Add additional ip's to lo interface in docker container
  • Restart Docker Containers when they Crash Automatically
  • docker-machine commands from C#
  • One Solution collect form web for “Using Docker Nginx, PHP, MySQL on Mac”

    No, this guide just show using nginx container in docker. But I see the container don’t have php installed. And you cannot install php-fpm inside this container.

    So, if you want to use nginx, php, and MySQL using docker you should pull:

    1. Container which run Nginx + PHP-FPM (I recommend this image
    2. Container run MySQL (

    Download images

    docker pull richarvey/nginx-php-fpm
    docker pull mysql:5.6

    Run MySQL Instance. Name it mysql56, and expose using port 3360

    docker run -tid -p 3360:3306 --name mysql56 -e MYSQL_ROOT_PASSWORD=123456 -v /root/docker/mysql56/data/mysql:/var/lib/mysql  -d mysql:5.6

    Run Nginx PHP+FPM instance. Link it to MySQL Instance, and name it project-dev

    docker run -tid --name project-dev --link mysql56:mysql -v $(pwd):/var/www/html -p 8888:80 richarvey/nginx-php-fpm:latest

    Run docker ps -a to see the running containers.

    To make nginx can be accessed with address, just map it on /etc/hosts. Then access it on web browser


    • -v /root/docker/mysql56/data/mysql:/var/lib/mysql it mean I have /root/docker/mysql56/data/mysql on my mac, and map it to /var/lib/mysql in mysql56 container. So all mysql data will be backup on my local data, and will not lose when I remove the container.
    • -v $(pwd):/var/www/html mean your current directory will be mapped to
      container. So, whatever you write in this directory will be exist on
      /var/www/html container.
    • I use port 8888 to avoid conflict with existing web server, you can
      change it as you want
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.