We now know that Docker helps us build containers. But what exactly is a container?
A container is basically a single bundle — a single unit in which we have combined our application along with all of its dependencies. Our individual dependencies are no longer individual units. We have packaged our application and all of its dependencies into a single unit, and this single unit is what we share with our teammates and what we deploy or replicate.
For example, if we are on machine A and we want to replicate the environment to machine B, we simply create a bundle of our application and its dependencies, and share this single unit from machine A to machine B — without installing and setting up all dependencies individually. And the best thing about these containers is that regardless of whether machine B is running Mac OS, Windows, or Linux, the container will run on it.
So containers are basically a standardized way to share our application with its dependencies, essentially replicating the entire development environment in a standardized way across a large team.
Containers as a unit can be shared across teams. In Docker technical terms, we don't exactly share a container as a container — instead, to share a container, we share the Docker Image. This is something we will learn about gradually in this lecture.
Containers have very less overhead, which makes it fairly simple to create, update, have multiple containers on a single machine, and also delete them. The size of Docker images and containers is very small compared to something like a virtual machine.
Let's say we have a local machine on which we want to build two applications, and both are Node.js applications. If our machine has Node version 16, both applications will use version 16.
But if we want a setup where one application uses Node version 16 and another uses Node version 20 on the same machine, we can use containers for this. We build the first application on Container 1 and the second on Container 2. Containers carry their own separate environment compared to the host machine. The host machine may have any version of Node, but inside the containers we can use different versions of the same technology and build multiple apps in parallel with different versions of the same dependency.