In recent years, software containers that allow applications and processes to run in isolation have gained traction in the IT community. The open-source container platform Docker is the top player in this space and big IT vendors have been tripping over themselves to incorporate its software containerisation technology into their own offerings. Open source software provider Red Hat has been working with Docker since 2013 and has provided some key learnings on what not to do when using the container tool.
Unlike typical virtual machines, containers are easily disposable and that’s one of the advantages of using Docker. You can quickly get a bunch of container up and running for testing multiple applications each in their own self-contained environments. These containers can host different types of operating systems separately, all in one physical machine. Applications can then easily be packaged up and put in production.
The advantages of containers for developers are evident but there are pitfalls that they should avoided to get the best out of this technology. Over at the Red Hat Develop Blog, senior software engineer Rafael Benevides goes through what not to do in a Docker container to ensure developers can make the most out of it.
One of the things he advises against is to ship applications in two pieces using Docker. He explains:
"As some people see containers as virtual machines, most of them tend to think that they should deploy their application in existing running containers. That can be true during the development phase where you need to deploy and debug continuously; but for a continuous deployment pipeline in QA and production, your application should be part of the image. Remember: Containers should be immutable"
Another recommendation Benevides has is to avoid using a single overlay image to make the most of the layered filesystem:
"[A]lways create your own base image layer for your OS, another layer for the security and user definition, another layer for the lib installation, another layer for the configuration, and finally another layer for the application. It will be easy to recreate and manage an image, and easy to distribute."
Also, don't create images from running containers. If you do this, the image is not reproducible and not versionable.
You can read more about things you should avoid doing in Docker containers over at the Red Hat Developer Blog.
Further Reading: Dockercraft Lets You Manage Your Docker Containers Through Minecraft
[Via Red Hat Developer Blog]