Cloning the MAMP concept with Docker -- DAMP stack: Docker, Apache, MySQL, PHP, etc

The "DAMP Stack" is a tongue-in-cheek play on LAMP, MEAN, MAMP and other "stacks". The idea is using Docker instead of the MAMP or WAMP applications while developing code on a Windows or Mac laptop. MAMP and WAMP help users of Windows or macOS machines to easily run Apache+MySQL+PHP/Perl/Python services, either to develop LAMP Stack code, or to host LAMP Stack systems on a server in an office situation.

Developers and system administrators both need the best solution for running web applications on the computer they're comfortable with. MAMP and WAMP were a godsend for running or developing LAMP Stack code when they were first released. But today Docker enables us to do far more than MAMP or WAMP ever could.

Where MAMP and WAMP focused on the Apache webserver, the MySQL database, and languages like PHP, Docker enables running nearly any application stack, any database engine, and any anything else.

Consider what used to be the holy grail combination of MySQL, Apache and PHP (or Python). One thing that made macOS so popular for developers is it supported Apache and PHP out of the box, and adding a MySQL server was very easy. MAMP put all that together in a neatly packaged application for macOS, and WAMP did the same for Windows.

With Docker, that combination is a few minutes work writing a Docker Compose file to configure the required Docker containers.

Going beyond that, because Docker can containerize nearly anything which can be installed on Linux, its potential is nearly limitless. Docker offers developers a powerful development environment on their laptop, and the ability to deploy the exact same containerized application anywhere from the office server to globe spanning deployments on cloud hosting platforms.

Disclaimer: This tongue-in-cheek "DAMP Stack" is completely unrelated to a product named DAMP from Acquia, almost 10 years ago. That DAMP product obviously had nothing to do with Docker, because the 'D' meant Drupal. Here, the 'D' is all about Docker.

This guide is about setting up a Docker-based development environment, as well as low end Docker deployment.

Getting started with Docker: Installation, first steps

(October 8, 2020)

Let's start this journey into Docker by learning how to install it on popular systems, namely macOS, Windows and Linux. Installation is very simple thanks to the hard work of the Docker team. You youngsters don't know how easy you have it now that Docker for Mac and Docker for Windows exist. Long gone are the days when we had to install VirtualBox along with a specialized virtual machine to use Docker.

Wordpress production deployment with Docker Compose

(September 25, 2020) Hosting a Wordpress site in Docker is relatively easy, and is largely a matter of properly configuring three standard containers. It requires a MySQL database, NGINX, and the Wordpress PHP-FPM container, with simple configuration. Starting from a freshly provisioned virtual server, the process takes less than two hours to set up hosting with HTTPS support.

Wordpress local development environment with Docker on your laptop

(September 23, 2020) We normally install Wordpress on a public Internet server, and installation on your local machine is normally limited to developing or testing a Wordpress feature or theme. The development loop is a lot shorter when you can directly edit Wordpress files on your machine, as opposed to working out a method to edit remote files. While it's convenient, it's not always clear how to create a website hosting environment on your laptop. In the past we would use MAMP (or the Windows equivalent), which is a macOS-native environment for running Apache/MySQL/PHP stacks. But today we have a different tool, Docker, that is easily able to run that stack, as well as any other stack. Docker easily runs on a laptop, so let's take a look at using it to run a local Wordpress development environment.

Using multiple databases and PHPMyAdmin in a single MySQL Docker instance

(September 20, 2020) Sometimes our applications need multiple database instances, but with a single database server. The MySQL container for Docker is easy to use, but supports only a single database instance per server container. Obviously a MySQL server can support lots of databases, with lots of user identities, and it has a fairly nice system for controlling access based on IP address and user-names-and-passwords. In this article let's learn how to go ahead and configure the MySQL container for Docker to support multiple databases each with their own user ID.

Using NGINX, Lets Encrypt and Cron in Docker to manage HTTPS/SSL certificates for multiple domains

(July 5, 2020) NGINX is a hugely flexible webserver with which it's very easy to manage HTTPS with Lets Encrypt. With a simple configuration file it is easy to add HTTPS support to a back-end service, using NGINX's reverse proxy. It's possible to use this for deployments both small and large. As with any website Internet-visible nowadays, it is necessary to use HTTPS. Which leads to the task of using Lets Encrypt to provision SSL certificates for several domains, using NGINX to terminate the HTTPS connections, while proxying from NGINX to the actual services. This blog post discusses a Docker container designed explicitly for that purpose.

Manage Letsenrypt HTTPS/SSL certificates with a Docker container using Cron, Nginx, and Certbot

(June 29, 2020) Modern websites must have HTTPS support for security reasons. As a result web browsers and search engines have begun downgrading sites that do not support HTTPS. That means we all must have a simple, low cost, way to set up HTTPS support on our websites. The Letsencrypt project offers free SSL certificates for HTTPS. In this project we will create a Docker container for handling HTTPS via Nginx, and automated SSL certificate renewal using the Letsencrypt command-line tools (Certbot).

Remotely control a Docker Engine or Docker Swarm in two easy steps

(June 1, 2020) How do we manage a Docker instance on another computer? We can SSH into that instance and run Docker commands there, but a not-well-documented feature built into Docker lets us remotely access, and manage, Docker Swarm clusters or Docker Engine instances. It's fast, easy and very powerful.

Installing Gitea for self-hosted Git service, replacing Gogs

(March 11, 2020) While Gogs is an excellent tool to have a self-hosted Git service (like Github), I recently found out the project is semi-abandoned. A group of Gogs users launched Gitea as a replacement, and in any case it looks like a better server. The goal here is to install Gitea, evaluate it, and see how to convert Gogs-based repositories over to Gitea. The result will be managed in the Docker self-hosting machine I have at home.

Easily manage Docker containers on both local and remote Docker hosts with Portainer

(March 9, 2020) Docker is a wonderful advancement for software engineers and system administrators. It simplifies launching and maintaining background processes, while adding a layer of much-needed encapsulation and security. But the default command-line administrative tools are less than pleasant to use, and we instead want a good GUI with which to manage our Docker hosts. That's where Portainer comes in. It manages the Docker containers we have running on our local host, or on remote hosts.

Understanding MySQL the Access Denied error in or outside a Docker container

(February 20, 2020) The other day I wasted more than a full workday in which MySQL Access denied for user (using password: YES), and I want to help others avoid this problem. Along the way to fixing the issue, I learned a lot about how MySQL authenticates user ID's. I've been using MySQL for years and had glossed over this topic, but it turns out to not be terribly difficult.

Scheduling background tasks using cron in a Docker container

(May 27, 2018)

Sometimes you want a Docker container to execute background tasks, and therefore want cron to be installed and running. Having cron running in the background is part of normal Unix/Linux/etc system admin practices. Even though the crontab format is kind of hokey, we all learn it and set up automated background tasks to keep the world functioning. Let's see how to set this up in a Docker container.

HTTPS with nginx, using Lets Encrypt, proxying to Gogs and Jenkins back-end services

(March 31, 2018)

Modern development environments require a continuous integration system, along with a reasonable git-based repository hosting service. It's possible to rent these services, Github and Gitlab are both excellent hosted git repository services for example, and there are several hosted continuous integration systems. Gitlab in particular is a one-stop-shop offering both Git hosting and continuous integration in one service. But, you can easily host Git and Continuous Integration services on your own hardware. And with a little work the services can be HTTPS-protected using Lets Encrypt.

Connect with SSL to MySQL in Docker container

(March 5, 2018)

MySQL throws an error if you connect without using SSL, so therefore the MySQL team is making it clear it's best to use SSL. Clearly a database connection has critical data that you don't want to leak to 3rd parties, and encrypting the database connection is preferred. What's even more preferred is tight control to limit visibility of the database connection. The official MySQL Docker container automatically generates a set of SSL certificates to use for connections, so let's see how to put those certificates to use.

Set up MongoDB Docker image

(March 4, 2018)

MongoDB, as one of the popular NoSQL databases, is part of many software development projects. Hence, one must know how to configure and setup MongoDB in a Docker environment.

Set up MySQL Docker image on your laptop, then verify it works using phpMyAdmin

(November 30, 2017)

Setting up MySQL on Docker is fairly simple, and the MySQL team has done a credible job creating a flexible Docker image that can be used in many circumstances. Once the MySQL container is set up, you need a method to verify it can be accessed from other containers, and to manage the database it contains. Enter the mysql-client and phpMyAdmin Docker images. Both are easy to set up, and easy to use. Typically when deployed as part of an application stack, the MySQL container won't be visible to the public Internet but does need to be visible to other containers in your deployed application. Hence, there must be a private bridge network the containers use to communicate with each other, and the only ports published are what's required to supply the service to the public.

Unlike the MAMP product, what's shown here is equally applicable to macOS and Windows laptops.