Below you will find pages that utilize the taxonomy term “Docker”
Improvements in personal website deployment
I wanted to be able to deploy MailComments to my Digital Ocean droplet (VPS) easily and without thinking. Due to a lack of maintenance, some more “operations” work had piled up as well:
- The Digital Ocean monitoring agent had to be upgraded, but
apt
didn’t have enough memory to do that on this old, small droplet. - The Ubuntu version running on that droplet was also a bit old by now.
- The easiest thing to do was to just create a new droplet and prepare it for deploying my personal websites.
- Unfortunately, my DNS setup was completely tied to the IP address of the droplet, so I couldn’t really create a new droplet, and quickly switch. I’d have to wait for the new DNS information to propagate.
These issues were in the way of progress, so I decided to take some more time to rearrange things.
Defining multiple similar services with Docker Compose
For my new workshop - “Building Autonomous Services” - I needed to define several Docker containers/services with more or less the same setup:
- A PHP-FPM process for running the service’s PHP code.
- An Nginx process for serving static and dynamic requests (using the PHP-FPM process as backend).
To route requests properly, every Nginx service would have its own hostvcname. I didn’t want to do complicated things with ports though - the Nginx services should all listen to port 80. However, on the host machine, only one service can listen on port 80. This is where reverse HTTP proxy Traefik did a good job: it is the only service listening on the host on port 80, and it forwards requests to the right service based on the host name from the request.
Making a Docker image ready for use with Swarm Secrets
Here’s what I wanted to do:
- Run the official
redis
image as a service in a cluster set up with Docker Swarm. - Configure a password to be used by connecting clients. See also Redis’s
AUTH
command. The relevant command-line option when starting the redis server would be--requirepass
.
This is just a quick post, sharing what I’ve figured out while trying to accomplish all of this. I hope it’s useful in case you’re looking for a way to make a container image (an official one or your own) ready to be used with Docker Secrets.
Docker build patterns
The “builder pattern”
As a programmer you may know the Gang-of-Four Builder design pattern. The Docker builder pattern has nothing to do with that. The builder pattern describes the setup that many people use to build a container. It involves two Docker images:
- a “build” image with all the build tools installed, capable of creating production-ready application files.
- a “service” image capable of running the application.
Sharing files between containers
At some point the production-ready application files need to be copied from the build container to the host machine. There are several options for that.
Containerizing a static website with Docker, part III
In the previous posts we looked at creating a build container, and after that we created a blog container, serving our generated static website.
It’s quite surprising to me how simple the current setup is — admittedly, it’s a simple application too. It takes about 50 lines of configuration to get everything up and running.
The idea of the blog
container, which has nginx
as its main process, is to deploy it to a production server whenever we feel like it, in just “one click”. There should be no need to configure a server to host our website, and it should not be necessary to build the application on the server too. This is in fact the promise, and the true power of Docker.
Containerizing a static website with Docker, part II
In the previous post we looked at the process of designing a build
container, consisting of all the required build tools for generating a static website from source files. In order to see the result of the build process, we still need to design another container, which runs a simple web server, serving the static website (mainly .html
, .css
, .js
and .jpg
files).
Designing the blog
container
We’ll use a light-weight install of Nginx as the base image and simply copy the website files to the default document root (/usr/share/nginx/html
) (only after removing any placeholder files that are currently inside that directory). The complete file docker/blog/Dockerfile
looks like this:
Containerizing a static website with Docker, part I
Recently a former colleague of mine, Lucas van Lierop, showed me his new website, which he created using Spress. Lucas took two bold moves: he started freelancing, and he open-sourced his website code. This to me was very inspiring. I’ve been getting up to speed with Docker recently and am planning to do a lot more with it over the coming months, and being able to take a look at the source code of up-to-date projects that use Docker is certainly invaluable.