This article was originally published on Conetix by Tim Butler. With his kind permission, we are sharing it here for Codeship readers.
Unless you’ve been living without internet access for the last two years, it would be hard not to at least have heard of Docker. But as an emerging technology, not everyone has taken the time to work out what Docker is, where it fits in, and how it can benefit you.
So, what exactly is Docker? Here’s how Docker themselves describe it:
Docker is an open platform for developers and sysadmins of distributed applications.
Essentially, Docker is a container-based system for your applications. If you’re used to the concept of virtual servers, Docker provides further levels of abstraction for your application. Here’s a visual representation of how containers differ from VMs:
Rather than just being one part of the puzzle, Docker provides a number of components and tools to assist with the entire lifecycle management of the application. This includes the container environment, image management, and orchestration.
Docker started its life as an internal project within a hosting company called dotCloud, but it quickly took off once they open sourced it in early 2013. Since then, it's benefited from over 15,000 software commits from over 900 contributors.
Why Use Docker?
Now that you have a basic understanding of Docker, there are a number of great reasons to start using it.
It’s very fast. Start a Docker container, and it can be complete in as little as 50ms. That’s not a typo; it really can be this quick! This is the advantage of having such high levels of abstraction -- you reduce the number of components you need to run. This also means that there's very little to no overhead in its implementation.
One command deployments. It really is as simple as installing an application with one line. Want to install MySQL? One command. Want WordPress, MySQL, Nginx, and Memcache all installed and configured? Yep, it’s one command.
Pre-configured apps. At last count, there were over 13,000 applications already packaged as a Docker image. Chances are, if you’re using a common application, most of the initial work has already been done for you. But it doesn't end there. You can take the existing image, make your own changes, and push it to your own repository for ease of redeployment.
Resource isolation. Previously, if you ran all of your services on the one server, then there’s a chance one of them could exhaust all of the server resources. Docker allows you to set, monitor, and adjust these on a per application or service basis.
Consistency. Docker really is the “write once, deploy anywhere” type of environment. It removes all of the hassles from a development to a production environment or similar. Each set of libraries is very tightly coupled to the Docker image to ensure consistency.
A complete platform. Rather than just being one part of the puzzle, Docker is shaping up to be a complete platform. There’s the base Engine for the containers, the Registry for image management, Compose to orchestrate complex deployments, Swarm for clustering, and Machine for provisioning. This is what’s made Docker different from other container implementations -- you can manage the entire lifecycle quite easily.
Scale. This is is one area where Docker really shines, especially if you have a microservice-based application. Compose and Swarm assist with deploying scalable applications, and then there are third-party tools like Kubernetes and Mesos, which both take it to the next level. We’re talking the ability to manage the entire lifecycle with up to millions of containers, so scale isn’t a problem!
Why Not to Use Docker
This probably seems like a strange topic to cover, but like any system, it’s important to understand the limitations and alternatives.
If it’s not broken, don’t fix it. Are you having issues with your current application deployment? Does it deploy perfectly each time? Do both developers and sysadmins get along perfectly without any blame or bouncing issues back and forth? If you answered yes to all of the questions, then Docker probably isn’t for you.
Docker is an emerging platform. This means that there are constant changes, and the toolset is constantly evolving. It also means that the “best practices” are also constantly changing, so you need to stay up-to-date with what’s going on. If you want to learn something once and never deal with change, then Docker probably isn’t for you.
You may need to change your architecture design. Docker containers are immutable by design. You need to think about and store persistent data in a separate volume. While this is a good thing when dealing with infrastructure at scale, it also means you need to carefully consider it. There’s also the networking side of things; the IP addresses and hostnames allocated to the container are done so at runtime. You need to design your Docker environment around this and use service discovery to handle it.
Not everything is suited to a Docker environment. Just because Docker is cool, it doesn’t mean it works with everything. It really comes into its element when you have a microservice-based system or single component. If your application has a lot of low-level system calls or needs hardware access, then Docker isn’t the platform for you.
Lastly, Docker isn’t the only application container platform. There’s already rkt (pronounced Rocket) from CoreOS which offers an alternative application container format and associated toolkits. They have a very similar amount of features but a slightly different focus. Canonical (the creators of Ubuntu) have been going down the path of LXD. While it isn’t a direct replacement for Docker, it does offer a lot of container-based orchestration tools.
Still excited about Docker? Excellent!
How Do I Get Started?
When should you start learning about Docker? The answer is now! You can begin with a very basic tutorial on the Docker website, which has a neat interactive guide through the basic commands.
The next step is to get a basic development environment set up on your local machine. Docker has some basic instructions available to get you started. We’ll also be continuing our set of articles on Docker, which will step you all the way from the basics through to real-life examples and advanced implementations. Keep checking back on this blog for updates or follow us via your preferred social media platform.
At Conetix, we’re excited about Docker and where it’s heading. We have already started using it for our production systems, and we’re launching a Docker-optimized hosting platform within the next two months.
Stay up to date
We'll never share your email address and you can opt out at any time, we promise.