Getty Images


Choose the best Docker image for the job at hand

There are a lot of varied options for container images. And although that freedom of choice breeds flexibility, it can also make it easy to choose the wrong one.

Docker images revolutionized the computing world, but not all images are created equal. Let's look at how to choose the best Docker image for the job at hand. Because while there are many suitable images your organization could choose, the best option depends on its context.

The difference in requirements between production-use and quick-and-dirty Docker images is vast. For personal use, a quick, disposable image works. For production images, official, stable and well-supported images work best. A single WordPress image is good for personal use, but not for a business. That said, WordPress is available as an official image.

In production, it is better to build your own container images to ensure the quality of the Docker image.

Layered images

Part of the flexibility of Docker images is that the system is built by stacking layers. While this might sound far from ideal, the leanness of a base image is optimized for performance with expandability and flexibility baked in.

Each command run adds another layer. The previous layer becomes read-only as additional layers are added. Image updates also create additional layers. For example, use the following command to see the layers of an Ubuntu image:

     docker history ubuntu

Figure 1 shows an example of the layers on the base Ubuntu image.

Screenshot of the layers of an Ubuntu image
Figure 1. The layers of the Ubuntu image.

Image layers also help ensure additional software can be installed onto standard base images to create a new server while continuing to share a same known base install. This reduces required maintenance.

For ease of use, Docker offers several prebuilt images. Companies can create their own, but the most common is Docker Hub, which is the default for most new users.

Official vs. unofficial images

Image integrity is key. Users must differentiate between officially sanctioned images and third-party images. While most available images are well intentioned, some can be downright malicious: Some popular-seeming images have had hidden cryptomining malware that is easy to miss.

Fortunately, there is a way to differentiate between official and unofficial builds. To restrict the results to official images only, use the following syntax:

     docker search --filter=is-official=true nginx
Screenshot of a Docker search for official images
Figure 2. A Docker search for official images.

Useful official Docker images

The following are some of the most useful Docker images:

Ubuntu. This is one of the most downloaded Docker images in the industry. It is the official OS for Ubuntu and is used as a base image for nearly every type of server OS. It is a small, slim image designed to be built upon. This image is easy to expand and include what resources are needed for a given task.

Alpine. For those who want something smaller, the Alpine Linux Docker image is the way to go. It is great to run on systems with constrained resources, but Alpine management requires a higher skill level and is not as user-friendly as Ubuntu. Unless there is an overriding reason to use Alpine, keep to the Ubuntu mainstream environment.

Nginx. Nginx is the current hot web and proxy server. This image is designed to be tiny and respond to use out of the box via mount point for the files.

MySQL. MySQL databases are a staple of the open source world. This container is easy to download, has a disposable SQL server for experimenting and can be deleted easily when finished. This is part of the benefits of Docker containers in general -- build, use and throw away.

Redis. For those after a speedy in-memory database, Redis is a good call. Redis is easy and quick to dabble with.

Elastic stack. Previously known as ELK, which stands for Elasticsearch, Logstash and Kibana, Elastic Stack provides log storing, searching and visualization. Again, this Docker image is disposable.

WordPress. WordPress is a bit of a wild card. Setting up WordPress manually, and securely, is a laborious process. Therefore, being able to pull down and run WordPress instantly is useful.

Notes of caution

If your organization uses Docker images for anything critical, bear in mind that even when they are official images, new ones are released and default to the latest. This means the image changes, often frequently. Docker Hub offers the ability for users to create and use one repository for free, so IT admins should ensure they keep close track of image version updates.

Ideally, keep images on an appropriate private Docker repository. As noted earlier, a personal project varies vastly from a highly managed, audited production environment at a midsize company. It is possible to use Docker images efficiently, but be careful.

Next Steps

How to compare Docker images with container-diff

Dig Deeper on Containers and virtualization

Software Quality
App Architecture
Cloud Computing
Data Center