Docker

Docker from Scratch, Part 6: CLI Containers and Helper Scripts

 
In the last post, we got our database container up and running. Combined with our web server container, we should have everything we need to get our application running, right? Well, kinda. For many applications, it’s useful to have one more container to act as a command line interface. That way, we can run whatever scripts or utilities our application requires. Building the CLI Container We’ll start off our CLI container just like with all our other containers, but adding a new cli...

Docker Circular Import Hell

 
Lately I've been stuck on a particular problem with my Docker container projects. Generally, I need three containers to run Drupal: A web server container, a database container, and a container to host any CLI tools. The latter isn't necessary, but it's very, very useful when working with Drupal core and module code. Drupal has two primary CLI tools, drush, and Drupal Console. These tools allow you to reinitialize the site, clear internal caches, install modules, and generate module code. You...

Docker From Scratch, Part 5: Custom Entrypoints and Configuration

 
In the last post, we introduced Docker Compose. Now, instead of looking up image IDs, managing our containers requires only a few easy to remember commands. We also used volumes to sync a directory on the host OS to the container for easier development. The wonderful thing about Docker Compose is that it can manage more than one container at a time. We can create multiple containers and manage them all as if they were part of the same, cohesive whole. In this post, we’re going to expand our...

Docker from Scratch, Part 4: Compose and Volumes

 
In the last post, we’ve created a repeatable web server container using a single file, the Dockerfile. While this is great, there’s one big limitation to a Dockerfile: It can only create one container. Docker containers are also only intended to run one process. What do we do if we want to run a web server, and a database, and a Solr instance, and a… We’d need to create a Dockerfile for each server process. Given that we’d need to call the Docker “run” command for each container, building...

Docker from Scratch, Part 3: Entrypoints and Ports

 
In the last post we used the RUN statement in our Dockerfile to setup and install software in our container. This saves us the trouble of creating build scripts that we need to run each time we start the container. We still have to specify the command to run when we start the container. What we want to do is eliminate that so we have less to remember each time we use the container. Background vs. Foreground Processes When a container is run, only a single process is run within it. Containers are less...

Docker From Scratch, Part 2: Dockerfiles

 
In the last post, we pulled an ran a Docker container from the command line. Even though we only needed a few commands, it can become tedious to run the same lengthy command over and over each time we want to work with our container. Worse, such repetition is prone to error. One thing we want from Docker is a repeatable environment: something that builds the same way each time we build it, on each system we build it on, for all the developers on our team. You might be tempted to just put everything...

Docker from Scratch, Part 1: Installing and your First Container

 
The last few months I’ve been engaged in a quest to understand something new to me. Since the mid-2000s, I’ve been using virtualization technologies to run classroom environments, test software, and run local web servers for development. First, it was using VMware Player, then Server, and today everything I virtualize runs on the open source Virtualbox. So when I heard about containerization, I was stunned. “How can you start tens of virtualized instances in only seconds? It’s unreal!” And...