Features

Container Antipatterns: 5 Mistakes to Avoid when Using Docker

To get the most out of Docker containers, it’s important to avoid mistakes that DevOps teams sometimes make when migrating to Docker. Here are the top five common Docker mistakes to avoid.

Those mistakes include:

Installing an operating system inside a Docker container. This can be done, but there is rarely a good reason to host an entire OS inside a container using Docker. If containerizing a complete OS is your goal, you’re better off using a platform designed specifically for that type of use case, such as LXD or OpenVZ—both of which are system container, rather than application container, platforms.

Running unnecessary services. When building your container image, you should include only the services that are absolutely essential for the app the container will host. Anything extra wastes resources and widens the potential attack vector that could lead to security problems. This is why you should probably not run an SSH server inside your container, for example. There is no need for SSH when you can use the Docker exec call to interact with the containerized app.

Storing critical data inside a container. This is a bad idea for two reasons. First, containerized data is not persistent by default, so you risk losing important data if the data exists inside a container. Second, storing sensitive data inside a container poses security risks because anyone who can access the running container—or, in some cases, even just the image registry that hosts the container image—could potentially gain access to private information.

Storing data other than container images inside a container registry. A container registry is designed solely for the purpose of hosting container images. Don’t use your registry as a general-purpose repository for hosting other types of data. That’s the mistake Vine made last year, when it was using a container registry to host source code.

Hosting too many services inside a container. In general, a container should host a single service. If your app requires other services, run them inside separate containers. Being able to compose your app in this way using multiple containers, with one service running in each container, is the major advantage of using Docker in the first place. Limiting each container to a single service may sometimes not be feasible—especially if your app was ported from a monolithic chunk of code that was not designed with microservices architectures in mind. But wherever possible, stick with one service per container.

Christopher Tozzi

Christopher Tozzi has covered technology and business news for nearly a decade, specializing in open source, containers, big data, networking and security. He is currently Senior Editor and DevOps Analyst with Fixate.io and Sweetcode.io.

Recent Posts

CloudBolt Taps StormForge to Help Rein in Kubernetes Costs

StormForge's machine learning algorithms that optimize Kubernetes clusters will be fed into CloudBolt's Augmented FinOps tools.

2 days ago

NVIDIA Acquires Run:AI to Run AI Workloads on Kubernetes More Efficiently

Run:ai enables IT teams to take advantage of container orchestration to schedule AI workloads across multiple GPUs.

2 days ago

Cosmonic Donates Kubernetes Operator for wasmCloud to CNCF

Cosmonic has contributed an Operator developed for the wasmCloud platform to the CNCF, enabling WebAssembly applications to run on Kubernetes…

7 days ago

Ensuring Efficient Cloud-Native Backup and Recovery

Cloud-native backup and recovery solutions can improve an organization’s cloud data resilience against accidents and online cyberthreats.

1 week ago

Latest Kubernetes Update Increases Enterprise Appeal

In total, 22 capabilities previously available in beta have graduated to stable. Many of those Kubernetes features appeal primarily to…

1 week ago

Red Hat Adds Developer Tools to Extend DevSecOps Reach

Red Hat added three new developer tools, expanding its DevSecOps portfolio for building secure cloud-native applications.

1 week ago