Overview

Skill Level: Any Skill Level

Ingredients

Most businesses are migrating to the cloud. According to Flexera’s 2019 State of the Cloud report, 95% of the 800 people surveyed are using cloud services. Startups can take advantage of adopting cloud workflows from the start. 


New organizations don’t have established processes and often have no technical debt. However, established organizations are often faced with migrating significant amounts of data and legacy applications. This type of migration can be a lengthy and complicated process. If you are in the latter category, containers can help you simplify the process.


In this article, you’ll learn what legacy applications are and how containers can help you move these applications to the cloud. You’ll also learn how to containerize a legacy application for migration.

Step-by-step

  1. What are Legacy Applications?

    A legacy application is a program that relies on outdated or obsolete systems. It can still be functional but is often unstable due to compatibility issues or lack of support. Legacy applications are retained by organizations for a variety of reasons, including technical debt, the difficulty of changing processes, or lack of alternatives.

  2. What are Containers?

    A container is a piece of software in which an application’s code and dependencies are bundled. It enables you to run applications in almost any environment because it does not require a specific Operating System (OS). 

    Containers are run on a container engine, such as Docker Engine, which interfaces with the host environment’s OS. A container’s flexibility and self contained nature enables you to easily migrate, launch, and scale applications and services.

  3. Why Use Containers to Migrate?

    Containers can help you plan a more efficient and effective cloud migration strategy. You do not need to re-architect legacy applications or data when using containers. Rearchitecting involves completely rewriting application code. Instead, the migration of applications with containers is accomplished with refactoring. Refactoring is the process of rearranging legacy code to fit new environmental and technological demands.

    Containers enable you to migrate applications and data without concern for OS compatibility. A container takes fewer storage resources to create and maintain than a Virtual Machine (VM).  VMs require you to include OS files and require a larger storage footprint. Containers’ smaller size also requires less bandwidth to transfer.

    Containers also enable you to take full advantage of cloud benefits, such as scalability and high availability. Depending on your deployment, containerized applications can be used for distributing workloads. Multiple, mirrored containers can provide resiliency by eliminating single points of failure. The flexibility of containers enables you to customize your systems in a way that traditional applications do not

  4. How Can You Migrate Apps With Containers?

    To refactor an application, you can take the following, simplified steps. These steps assume that you are using Docker containers. For an in-depth explanation, check out this tutorial.

    1. Break Down Your Application

    Before you can begin containerizing, you need to determine the components of your application. 

    Your considerations should include: 

    • What services the application needs to run 
    • What dependencies it has
    • Whether it requires persistent storage or not

     

    Any external services should be put in a separate container. Separating services makes updating easier and allows multiple applications to use overlapping services. For example, if multiple applications use Elasticsearch, you can create one microservice that those applications reference. 

    If your application requires persistent data storage, you need to determine where to store this data. Containers are ephemeral; data contained inside is lost if a container fails. You need to store persistent data and databases in a separate way that allows communication to and from your containers.

    2. Determine Your Base Images

    Base images define how your finished container connects and communicates with the host environment. These images form the foundation of your container image, or container software package. You can create images from scratch but it’s faster to use a good base.

    When choosing a base image, look for images that are stable and well maintained. Stable bases help you ensure that you will have consistent builds. These bases contain a standard set of libraries and directory structures that you know are reliable. Well maintained bases have up-to-date dependencies and security patching. 

    3. Define Your Configurations

    Provide your configuration specifics at runtime when you build the container. Configuration can include logging and log storage, database location, credentials, access controls, or application settings. 

    If your configurations will vary by environment, you need to assign environment variables for each setting. For example, you may want your application configured differently for test vs production environments.

    4. Add Application Code

    To add your application code, you need to modify your Dockerfile. A Dockerfile is a set of instructions for how to build a final container image. In your file, you add code using the ADD command. You need to specify the location of your app code, as well as where it should be stored in the container file structure.

    Depending on the complexity of your app, you can use scripts to compile your code at runtime. You can also manually compile, or build, your code and add it after compiling. If you compile before runtime, you may reduce the time it takes to build and run your container image. This is important if you need to be able to quickly restart failed containers.

  5. Conclusion

    Legacy applications should not hold you back from successfully migrating to the cloud. By containerizing legacy applications, you can retain your vital processes while gaining the advantages of a cloud infrastructure. Hopefully, this article helped you understand how you can use containers to migrate your legacy applications.

    If you’re ready to start tackling your legacy applications, your next step is to determine which applications are suitable for containerization. Check out this guide to help you decide.

Join The Discussion