


mkdir /Users//Develop mkdir /Users//Develop/docker_configs mkdir /Users//Develop/docker_configs/mysql mkdir /Users//Develop/docker_configs/redis mkdir /Users//Develop/mysql_data mkdir /Users//Develop/logs mkdir /Users//Develop/logs/apache mkdir /Users//Develop/logs/php mkdir /Users//Sitesīecause the /Users folder is already recognized by Docker for file sharing by default, there is nothing we need to do within the Docker file sharing preferences.
RUN DOCKER ON MAC FREE
Feel free to adjust the location to your own liking. Personal preference: I like to gather up my development tool items into a folder called Develop. Make sure to substitute your own macOS user name for. Open Terminal and enter the commands below. We’re also going to create a folder to hold the websites we build and this will be bound to the /var/www/html folder inside the PHP container. These will be bound during the Docker RUN statement to the appropriate folders inside the containers. We’re going to create some folders in our macOS user folder that will be used to hold config files for the Redis and MySQL containers as well as folders to hold the Apache and PHP log files so they’re easy to find and access.
RUN DOCKER ON MAC FOR MAC
If you haven’t already, install the latest version of docker for mac from the stable channel: Create local binding folders To accomplish this, we’re going to use a Dockerfile that will bring together all of the components we want in our development environment, including the Xdebug, Redis, and Igbinary PHP extensions.Īll three of these containers will be joined to the same Docker network so that Docker’s native DNS functions can come into play and the containers can talk to each other by name rather than IP address. The third and final container will be our Apache/PHP 7.2 localhost server.
RUN DOCKER ON MAC HOW TO
The second container will follow the instructions I previously provided in my articles How to Run MySQL in a Docker Container on macOS with Persistent Local Data, and be a MySQL 8.0 server operating as a localhost MySQL instance using Native Password Authentication. By running the Redis server separately, we will more closely mimic a production environment. The first will contain our Redis server that we’ll use for PHP session management. In this article, we’re going to create and launch three Docker containers. In addition, by putting my Apache/PHP environment inside of a container, I’m able to run additional containers side by side with different versions of PHP or containers running Wordpress. Second, by creating my development environment in containers I can easily set up my entire development environment on a new machine in a matter of minutes with only a few Docker commands. First, not only should I be able to run the exact same development environment across all version of macOS, but I should also be able to run these exact same containers on Ubuntu desktop if I chose to-or any other OS capable of hosting Docker. This opens up all kinds of possibilities.

Now that I’ve upgraded to macOS 10.15 Catalina, with its read-only file system volume, I decided to lift my development environment entirely off of macOS and run it inside Docker containers. I’ve written several articles about setting up a PHP localhost development environment on various macOS machine versions using Homebrew, including a couple of articles for running MySQL 8.0 in a Docker container.
