The Advantages of Using Docker for Web Development

Twain Taylor
codeburst
Published in
5 min readFeb 19, 2018

--

Containers have various characteristics that aid in front-end web development. In this article, we will examine how Docker containers are changing the face of front-end web development. Let us look at some of the benefits of using containers for web development:

Source: Flickr.com

High Fidelity Across Environments

One of the major concerns when developing applications is the myriad of issues that stem from the differences in environments between Production, QA, and Development. This also applies to the various developer machines that are being used on the project. Code pipelines generally have many moving parts — even a minor difference in one of the environments can lead to witch hunts to figure out and resolve a problem. With Docker images, which are immutable by nature, you can achieve consistency in environments from Dev to Production, ensuring that your code sails through QA and Production without many complications. Images also help with an organized approach to incremental updates as you can create a new and modified image based on an existing image. Various teams working on a project can use the base container image to download and create new container instances.

No more concerns like, which version of a web server is running and at what patch level, or if you accounted for a difference in QA and Production etc. Containers are an elegant solution for the dreaded ‘works on my machine’ syndrome.

As a result of minimizing the differences between environments, you can work with containers on your local machine/environment, boost productivity, and save yourself some hassle and time.

Isolation

With containers, you would generally want to run one application or process per container. A container runs in its own isolated runtime environment with process space and a network stack. This makes it easier to deal with security issues. For example, if there is a malicious script that ends up running on a container, only that container is affected and all other containers are safe. All you would need to do to bounce back is to destroy the affected container and spin up a new one from its image. Another security benefit is that a container can only access the ports and files explicitly exposed by another container.

An advantage of isolation is the ability to test without a big dependency overhead. Say you wanted to test your application with different sets of data and see how it reacts, you can switch out and change the connected database containers with as many sets of data as needed. Another example to consider is if you want to check how different versions of a library affect page rendering speed for your web interface. You can simply install different versions of the library in different instances of your front end container while keeping the application and database containers the same.

Modularity

As applications get more and more complex, the need to split up various parts of an application into discrete units becomes necessary to keep an application modular. This approach not only helps manage the complexity of changes or updates to the application it also helps make an application more agile. This saves you from performing an overhaul of the whole application for a change in one of the components. This also means you can modify and redeploy the environment of one of the application components without affecting the other parts of the application. So, for instance, if the database needed a security patch, it can be patched and deployed as a new container instance and your web part would not need any changes or redeployment.

Similarly, for much more complicated multi-tenant applications, a modular approach helps save time and resources by allowing you to create multiple instances of app tiers for each tenant. Not only does it allow you to keep the various components and tiers organized it also allows you to spin up containers programmatically via the Docker API.

Speed

Imagine you have a new colleague to help you with your web development efforts. Traditionally you would need to walk them through the setup of the environment for development and ensure all dependencies and libraries are installed and match the current versions being used. With the container based approach, all that is needed is an installation of Docker and then a download of the images to spin up the containers. The operating system used by your colleague would not be a cause for concern either. This simplifies the onboarding process for new resources.

Since Docker instances are lighter than virtual machines, sharing images with your team is a much more efficient proposition. This also means you can run a lot more containers than virtual machines on the same physical hardware.

Another prospect is the time to get up and running. You can have a container up and running in seconds compared to configuring and waiting for a virtual machine to boot up the OS.

Scalability

Containers are much easier to scale than virtual machines as they are neatly packaged lightweight pieces of the application that can have various parts spun up and load balanced as required. You can also have containers shipped quickly between different host environments in the event of a hardware failure or increased load. On the other hand, migrating virtual machines or traditional web or application servers is a much more complex and intensive process.

Conclusion

Docker and containers are a powerful way to manage environments in a DevOps pipeline. It helps alleviate many of the niggles associated with iterative code and rapid application deployment. Apart from this, there is a thriving community around Docker and this is a wonderful resource to help developers troubleshoot and resolve issues along the way. There are prebuilt images for popular applications like WordPress which can be downloaded easily. One of the unintentional consequences of containers is enabling innovation — the ease at which you can deploy instances of containers and their near-instantaneous startup time allows you to experiment and make a lot more mistakes without serious consequences. The more mistakes you can afford to make, the more you can innovate. It is no wonder more and more DevOps teams are switching to containers to save time, resources and also to give them a leg up in terms of staying lean and competitive.

--

--