Why Use Docker?

Now that we've ran a Docker container and explored some of the components behind Docker, it'll be easier to visualize why developers want to use a tool like Docker. Some of the big benefits are:

  • Consistency
  • Developer productivity
  • Enable deployment automation

Consistency

When developing applications, we ideally want our environments to be consistent when it comes to the tools needed to run an application. After all, nobody likes it when an application works perfectly on one developer's machine, but then fails on a teammate's machine. Or even worse, fails in production.

Docker helps provide that consistency by creating containers in a repeatable manner. We've seen Docker containers being created from images. These images define how a container should be instantiated and run. As long as we're using the same image, we can create as many containers as we want on different machines, all packaged with the tools needed to run the application.

Developer productivity

Docker provides a robust toolset to help increase developer productivity.

  • Image Registry: We'll learn that we need images that instruct Docker on how to run a container. However, it would be very time-consuming if we had to build our own images for every type of application. Luckily, Docker provides a registry called Docker Hub. Docker Hub provides many public, free images for developers to use. There are images for a variety of applications and tools, like MySQL, Node, Nginx, Python, and Ruby. This makes it really easy to get started quickly. We'll also learn about creating our own images to share with others on Docker Hub.
  • Multi-container Applications: Most web applications will involve more than one container. An application may consist of multiple servers, databases, and other services. Each one will require its own Docker container, which can be a struggle to get set up. Docker provides a tool called Docker Compose that makes it easy to define and run applications that need multiple containers. After defining containers in Docker Compose, the entire application can be started using one command instead of several. We'll learn about this later as well.
  • Container Orchestration: When running multiple containers in a live environment, management can become even trickier. Containers may need additional configuration or need to run on multiple machines. Docker has tooling for "swarms", which are multi-container, multi-machine applications (also known as clusters). While outside of the scope of this course, information on swarms can be found here. Orchestrators such as Kubernetes are also very popular.
  • Documentation: Overall, Docker has great documentation for developers, along with guides and references to help you setup everything.

Enable Deployment Automation

All of the benefits above tie nicely into application deployment. Because Docker containers are replicable, consistent, and self-contained, deployment can often be plugged into an automated pipeline. We'll talk more about this when deploying a Docker container.


TL;DR: Docker can save developers a lot of time and effort because applications can be created in a replicable manner. Docker also provides benefits like robust tooling and an active community of developers.

Complete and Continue  
Discussion

0 comments