When talking about software containers it is helpful to start with its conceptual cousin known as Function-as-a-Service. Traditionally, in order to execute a particular web API call, an entire application is spun up with accompanying resources and is only torn down after a specified amount of time. Enter serverless computing where only a function or piece of business logic is deployed and is event-driven and instantaneously scalable. Resources are conserved and abstracted away saving time and money.
Now let’s parallel this experience with containers. Normally, if we wanted to host a database like Microsoft SQL Server, we would need a complete environment such a physical server or virtual machine and accompanying operating system. In order to execute the application, all the other resources would need to be spun up. Let’s not forget that this includes all the patches and updates to the operating system as well as the application. What if we could host and execute the application in a similar way as serverless functions?
Docker is a standard that allows applications to be deployed inside software containers. The container allows for resource isolation (CPU, memory, I/O, network, and so on) and doesn’t require starting any virtual machines. Docker extends a common container format that runs processes in isolation. It also provides namespaces to completely isolate an application’s view of the operating environment, including process trees, network, user IDs, and file systems. The ability to provide lightweight platform abstraction within the Docker container, without using virtualization, is much more efficient for creating workload bundles that are transportable between clouds.
Containers have a few basic features and advantages, including the ability to:
- Reduce complexity. Containers don’t require dependencies on the application infrastructure. Thus, you don’t need a complex native interface to deal with platform services.
- Leverage portability. Automation replaced manual scripting. These days, it’s much more difficult to guarantee portability when using automation.
- Provide security and governance. Security and governance services are platform-specific, not application-specific. Placing security and governance services outside of the container significantly reduces complexity.
- Provide distributed computing capabilities. This is due to the fact that an application can be divided into many domains, all residing within containers. The portability aspect of containers means they can execute on a number of different cloud platforms. This allows engineers to pick and choose the platforms that they run on, based upon cost and performance efficiencies.
- Provide policy-based optimization. There needs to be an automation layer that can locate the best platform to execute on, and auto-migrate to that platform. At the same time, it must automatically deal with needed configuration changes.
The Docker container is simply an instance of a Docker image, much like applications are instances of executables that exist in memory. So, you can launch multiple isolated instances of the app as containers on a single host. Building a Docker image for an application requires starting with a base image for the core OS, which runs in Docker. Install and configure the necessary tools, and then use the Docker “commit” command to save the container as an image. Finally, push it to the public Docker image registry or keep it private.
Another way to create an image is to note the steps required to build the image in a well-formed Dockerfile file. This automates the process of installing and configuring the application, creating a repeatable process.
As with any development process, there are more details that you need to understand to master building and running Docker images and containers. In many respects, the success of containers and Docker has been around the ease of development. As the standard and product progresses, things will likely get even easier.
The first thing that needs to be done is install Docker on your local machine for development purposes as well as learning. The instructions for Mac or Windows can be found at the following URL:
Docker has great documentation as well as training. Here are a couple of resources: