Using Docker to deploy applications, encapsulate software tools, and otherwise simplify software development

Self-hosting services using Docker

(2021-05-04T01:31:15.562Z) Self-hosting is the opposite of using a 3rd party cloud service like Dropbox or Google Drive, and instead to host an equivalent service, like Nextcloud, on their own hardware. For every popular cloud service there is probably an independently developed open source equivalent one can host on their own hardware. Self-hosting gives one control, and peace of mind that their private information is not being sold to others, and it can save a lot of money from service fees that aren't paid. The personal security implications are huge, since it is known that governments around the world are pressuring internet services for data on user activity. While there is a legitimate need to know about criminal activities, do we really need to risk our data being snooped upon?

Self-hosted Docker infrastructure in home or office using low-cost computers like Intel NUC

(March 26, 2021) Using Docker, and a simple small computer, you can build a powerful computing "cloud" in your home, on your desktop, at low cost, giving you control over your data. If you need more power, adding another computer or three to the mix quickly adds more capabilities. For almost any popular 3rd party service like Github, Dropbox, and Trello, there is an open source package that might even be better. Those cloud services are temptingly easy to sign up and get going, but there are tradeoffs. What happens when a 3rd party service suddenly shuts down? That has happened on multiple occasions, sometimes deleting customer data in the wake. Or what about miscreants breaking in and stealing data? With open source operating systems, open source packages like Gitea, Nextcloud, and Kanboard, you gain control over your destiny.

Scheduling background tasks using cron in a Docker container

(March 25, 2021) The cron service has, for time immemorial in Unix-like systems, long helped us schedule the occasional background process that keeps our systems ticking. Typically it is used to gather up or summarize log files, or collect and process data from external systems. In the old days when e-mail exchange, and the all-too-important Usenet news exchange, happened using UUCP over modem lines, a cron job scheduled regular UUCP calls to neighboring servers. 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.

Using multiple databases and PHPMyAdmin in a single MySQL Docker instance

(March 20, 2021) Sometimes our applications need multiple database, but with a single database server instance. The typical recommendation is for each Docker container to serve a single application. For databases, that means one database server for each application. That's the result of following a theoretical best practice, but isn't there another best practice to avoid excess processes and overhead? MySQL, like most other database servers, can support multiple databases, multiple user identities, and has an extensive system for controlling access on IP address, user names, and passwords. The MySQL container for Docker is easy to use, but supports only a single database instance per server container. 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.

Connect with SSL to MySQL in Docker container

(March 17, 2021) MySQL might throw an error when an application connects without using SSL to encrypt the connection. Therefore the MySQL team clearly hints it is best to use SSL connections to MySQL servers. Clearly a database connection has critical data that you don't want to leak to 3rd parties, and encryption is a great counter-measure. 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.

Using SSH to remotely control a Docker Engine or Docker Swarm in two easy steps

(March 15, 2021) To remotely manage a Docker instance, we can SSH into that host to run Docker commands there. But a not-well-documented Docker feature lets us remotely access, and manage, Docker instances from the comfort of our laptop, via SSH. It's fast, easy and very powerful.

Set up MySQL using Docker on your laptop

(March 10, 2021) Setting up MySQL on Docker is fairly simple, and the MySQL team has created a flexible Docker image that can be used in many ways. Databases, like MySQL, serve as the data persistence and retrieval layer of many applications we might deploy.

Running MongoDB with Docker and Docker Compose

(March 10, 2021) MongoDB, as one of the popular NoSQL databases, is part of many software projects. Hence, one must sometimes know how to configure and setup MongoDB in a Docker environment.

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

(March 10, 2021) I once wasted more than a full workday fighting the MySQL error message Access denied for user (using password: YES). After finding the solution 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 both not be terribly difficult, and very crucial to the solution.

Wordpress local development environment with Docker and Docker Compose on your laptop

(March 9, 2021) 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.

Deploying MySQL to get started using a Docker Compose file

(March 8, 2021) While the docker run CLI command is powerful, Docker Compose files let us succinctly describe a whole system of Docker containers, virtual networks, and file systems, in one easy to read file. This is a powerful tool with which you can easily describe deployment of a full application stack. Compose files support not only deployment to the local Docker host, but to Docker Swarm clusters, and now to AWS ECS and Azure ACI cloud platforms.

Set up PHPMyAdmin and Wordpress Docker containers using existing MySQL

(March 5, 2021) There are several ways to launch a PHP service, backed by a MySQL database, on Docker. That combination is literally the LAMP Stack (Linux, Apache, MySQL, PHP/Python/etc), and we can use Docker to easily set up this combination on our laptop or deploy it to a production server. Elsewhere we went over setting up MySQL on Docker, so lets now demonstrate the LAMP Stack, on Docker, by deploying PHPMyAdmin and Wordpress on our laptop.

Familiarizing ourselves with Docker

(March 4, 2021) Getting to know Docker by running a few commands.

Implementing HTTPS with Docker services on AWS ECS using Docker Compose

(February 5, 2021) Thanks to a new Docker CLI feature we can directly deploy to AWS Elastic Container Service (ECS) using a Docker Compose file. It's very cool, and greatly simplifies deploying applications to AWS, but it lacks an important feature which is implementing HTTPS support. The solution offered by the Docker team involves rewriting the Cloud Formation template they generate for us, so let's learn how it works.

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.

Self-hosting your own web services in place of using 3rd party services

(September 27, 2020) Self-hosting is about hosting Internet services on your computers, controlled by you. This is different from just to just Use the Cloud by signing up for services like Dropbox, Github, Travis, or other 3rd party controlled services. Many people just use the cloud that way, because it's easy to just sign up, provide a credit card number, and get on with business. For each of those commercial services there are equivalent open source alternatives you can host on your own hardware. Self-hosting purposely takes a different route, and in this article we'll go over some reasons why.

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.

How to share a Docker network between Stacks deployed to a Docker Swarm

(September 20, 2020) How do you handle a system deployed to Docker Swarm, with multiple Stacks, where a container in one Stack must communicate with a container in another Stack? For example, you may have a database Stack, and an application layer Stack, where the application needs to communicate with the database. It's simplest to put both into the same Stack. But it's a best practice for the database to stay running, and to separately bring the application up and down to deploy updates. Therefore it's best to use separate Stacks for each layer, raising the question of how will the application containers find the database containers.

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).

Avoid 'could not be accessed' error when deploying a Service to a Docker Swarm on AWS

(May 30, 2020) Launching a Docker Swarm on EC2 instances is relatively easy, but of course there are pitfalls. One involves deploying a service to the swarm, but getting an error message about being unable to access the container image from the ECR registry.

Creating a Docker Swarm using Multipass and Ubuntu 20.04 on your laptop

(May 21, 2020) Docker is a cool system for deploying applications as reusable containers, and Docker Swarm is a Docker Orchestrator that let's us scale the number of containers across multiple machines. Multipass is a very light weight virtual machine manager application running on Windows, Linux and macOS, that let's us easily set up multiple Ubuntu instances on our laptop at low performance impact. Therefore Multipass can serve as a means to easily experiment with Docker Swarm on your laptop, learning how it works, setting up networks, etc.

Correctly launch MySQL on Docker for Windows, avoiding 'Bind on unix socket' error

(May 6, 2020) Docker is an excellent tool for launching Linux-containerized applications, and it even runs on Windows. But running Docker containers on Windows has a few unexpected rough edges. One will come if you try the default way to launch MySQL doesn't work on Windows. Instead of the expected successful launch you might instead be told Can't start server : Bind on unix socket and asked whether there is another MySQL server running. That misleading error can send you on a tangential wild goose chase.

Solve 'Drive has not been shared' error with Docker on Windows

(May 5, 2020) We often mount folders into a Docker container to ensure data is persistent while letting us freely destroy and recreate the container. But on Windows you might get a head-scratching error message saying "Unhandled exception: Drive has not been shared". The most common advice that might come up when searching the Internet is not about this situation, but about general file sharing in Windows. In this case the error refers to configuration settings in Docker.

Setting up Docker for an easy-to-configure self-hosting environment

(March 15, 2020) Self-hosting is about hosting Internet services in an easy-to-manage environment. Docker is an excellent tool for managing these kind of services since it is easy to reuse software packages, and it has a fairly strong security barrier around those packages. In many cases we'll just need to install and configure the Docker container. But to ease the task we need a well organized system for managing configuration files, data directories, and other stuff associated with running several Docker containers.

Installing a self-hosted Docker Registry to aid Docker image development

(March 15, 2020) When developing Docker images it's useful to store them in a Docker registry. While using Docker Hub is free, it's bad form to fill up that shared resource with images built for personal use. It's better to only publish the Docker images that are truly useful to everyone, and that have documentation. That leaves us with the problem of a location to host our own Docker images. Do we pay for a private repository somewhere? Or, as a self-hoster, do we host a local Docker Registry to store our personal Docker images? In this post let's explore the latter idea.

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.

Directly deploying a Docker service to AWS ECS using Docker Compose

(February 6, 2020) Deploying Docker services to AWS ECS is becoming much simpler thanks to new feature collaboration between the Docker and AWS teams. It is now possible to take a normal Docker Compose file, using modern Compose features, and deploy directly to AWS. Nothing complex or unusual is required, with all the complexity handled under the covers with a generated CloudFormation file. In this article we'll take a first look at using these features, which are in early release right now.

Run Linux/X11 apps in Docker and display on a Mac OS X desktop

(December 10, 2019) While the MacPorts and Homebrew projects bring many Linux apps to the Mac environment, they don't support every app we'd want to run. Since the X11 environment is not native to macOS it's not a simple recompile, since you have to rewrite the GUI system. Thankfully there is an X11 display server for Mac OS X that can be used to run an application in a Linux environment and display it on the macOS desktop. In this article we'll look at one way to get this all connected up and running.

Learn to use Docker for application development and deployment

(April 3, 2018)

Docker is a wonderful tool that abstracts away all kinds of details about configuring and maintaining Linux Containers. The power to simply type "docker run image-name" and have a bunch of complexity automatically handled is great. However Docker is one of those tools with lots of moving parts behind the scenes, and some training is needed to use it well.

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.

Moving Docker's files to a custom location

(January 30, 2018)

Docker is a wonderful tool that abstracts away all kinds of details about configuring and maintaining Linux Containers. The power to simply type "docker run image-name" and have a bunch of complexity automatically handled is great. But you may want to change Docker's defaults, and just how do you do so? In my case "/var/lib/docker" would be on an SSD drive, and to lengthen its lifetime I want to minimize the number of writes to that drive. Moving this directory to the SSD should help with that goal.

Deploying Docker images to a server without using a Docker Registry

(August 30, 2017)

We formerly deployed server applications to a Linux server using manual processes. An advanced team might use shell scripts to automate deployment. Over time tools like Chef or Ansible and more grew to handle ever-more-complex server application deployment scenarios. A few years ago, Docker came onto the scene with a whole new approach involving building a "Container" housing a complete operating system image that runs your application. Having built the Container, it's easy to ship that container to a server or run it on your laptop. The compelling gain is having the exact same development environment on your laptop as is deployed to your servers. Using the EXACT same environment streamlines your work by removing a ton of potentially destabilizing variables.

The preferred method is to build a Docker container image on your laptop, or on a build server, and upload the image to a Docker Registry. The image can then be downloaded from the Registry onto any number of systems.

What if you don't want to, or cannot, use a Registry? You could instead deploy the source code to the server, and build the container image on the server. That's a very unwise move, and it's better to ship the container image to the server. Turns out that is easy to do.

Using Docker to host ARM toolchain to cross-compile C code

(2017-01-19 16:27) I'm starting up a project that will see me doing custom software development for an ARM single-board-computer running Linux. The recommendation isn't to do compiles ON the board, but instead to cross compile from a Linux workstation (Debian). But, I use a Mac laptop, as do most software engineers these days. While I could run VirtualBox to set up a Debian cross-compiling environment, Docker is much lighter weight. While Docker was originally targeted for deploying server applications, it is useful for packaging anything. In this case there's a ready-made set of Docker containers for cross-compilation including for ARM CPU's.