DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Manage Microservices With Docker Compose
  • 5 Simple Tips to Keep Dockerized Apps Secure
  • Top 10 Open Source Projects for SREs and DevOps
  • Build and Deploy a Flask Application Using Docker

Trending

  • Enforcing Architecture With ArchUnit in Java
  • The Evolution of Scalable and Resilient Container Infrastructure
  • Chat With Your Knowledge Base: A Hands-On Java and LangChain4j Guide
  • Traditional Testing and RAGAS: A Hybrid Strategy for Evaluating AI Chatbots
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. How To Build Docker Images for Windows Desktop Applications

How To Build Docker Images for Windows Desktop Applications

In this article, we discuss the advantages of moving applications to the cloud and describe how to create docker images for Windows desktop applications.

By 
Dmitry Narizhnykh user avatar
Dmitry Narizhnykh
DZone Core CORE ·
Feb. 26, 21 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
19.0K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

It used to be that people first downloaded their software onto a physical computer and then ran it. Now, with cloud computing, you no longer need to worry about awkward downloads. Instead, you can use all the same services online from anywhere and see updates in real-time.

Why Businesses Migrate Their Legacy Applications To the Cloud

  • Probably the first main reason for moving to the cloud is access to virtually unlimited computing resources. Cloud elasticity and scalability are essential elements of cloud computing. 
    • Cloud elasticity is the ability of a system to dynamically manage available resources based on current workload requirements.
    • Cloud Scalability is a scalable system infrastructure to meet growing workload demands while maintaining consistent performance appropriately.
  • Moving from the legacy Windows app to cloud computing lets you work anytime and anywhere so long as you have an internet connection. A cloud-based web service is accessible from any device.
  • In the current pandemic situation, team members are forced to work from their home offices. Using the cloud, your teammates can open, edit, and share documents anytime and from anywhere; they can do more together and do it better. Before the advent of the cloud-based workflow, employees had to send files back and forth as email attachments that a single user worked on simultaneously.
  • A public cloud provider owns the hardware infrastructure and is responsible for managing and maintaining it, so you don’t have to worry about maintenance. With a public cloud, you only need to focus directly on meeting your business goals.
  • Cloud computing reduces high hardware costs. You pay only for the actual consumption of resources.

Virtual Machines Vs Containers.

Containers and virtual machines (VMs) are the two main approaches to deploying multiple isolated services in the cloud. So how are they different?

Virtual machines vs containers

Virtual Machine (VM)

Before the advent of containers, “virtual machine” was a technology used to optimize server capacity. Virtual machines (and hypervisors) emulate physical computer hardware with a complete operating system. It’s as if you are running multiple computers with several different operating systems on the same physical server.

The hypervisor orchestrates and distributes available resources (processor, memory, storage, etc.) across multiple virtual machines as needed.

Containers

The container shares the host OS kernel as well as binaries and libraries with other containers. Common OS components are read-only. Containers are lightweight so that you can deploy multiple containers on a single server or virtual machine. You no longer need to dedicate an entire server to one application.

Advantages of Containers

The biggest advantage of containers (if we are talking about Docker) over virtual machine images is resource usage.

  • Containers are lightweight, so they are fast.
  • Containers consume fewer resources.
  • Docker containers typically start in seconds, which speeds up deployment.
  • Tearing down a Docker container is as easy as running the docker stop command and usually takes less than a second.

On the other hand,

  • Virtual machines take longer, as they go through the entire process of booting the entire virtual operating system each time!
  • Each VM includes a separate operating system image, which adds overhead in memory and storage footprint.

Scaling container instances is far faster and easier than deploying additional VMs. Data volumes can be shared and reused among multiple containers.

Docker Containers

Docker is currently the leading container toolbox to deploy microservices to the cloud.

A software container packages the code, its libraries, frameworks, and other dependent components. As a result, the application runs quickly and reliably in any environment, be it a local data center, a public cloud, or a developer’s laptop.

Docker Containers


Software containerization solves many of the challenges of software development and deployment, so we embraced this concept when moving our Windows desktop applications to the cloud.

The most suitable types of software to embed in a docker container are non-user interface applications that are run from the command line. Typically, Linux-based Docker images are lightweight and are widely used in cloud environments.

Unfortunately, in most cases, rewriting all of your Windows application code from scratch to make it cross-platform is too expensive and time-consuming. Besides, when it comes to platform design, sharing the kernel between Dockerized applications has significant limitations. For example, Windows containers will not be able to run on a Linux host.

Windows Container Base Images

Microsoft offers Windows containers to deliver containerized services on the Windows platform. Check out a good article from Microsoft that describes Windows docker container images that users can build from.

I will use an Insider Windows Server Core image as a base. This image includes a subset of the Windows Server APIs and is suitable for packaging typical .NET framework applications.

  • Insider images are >50% smaller than the .Net Framework Runtime Images.
  • Container startup into Windows PowerShell is 30–45% faster.

Administrator view of Windows PowerShell

Dockerizing DBConvert Tools

As an example, I will show how to build a Docker image for DBConvert Studio. It is a classic .NET Windows application running either in GUI mode or in headless mode from the command line. It is also a good source of Docker-related techniques if you want to customize your own Dockerfiles further.

Dockerfile
 




x
13


 
1
FROM mcr.microsoft.com/windows/servercore/insider:10.0.18362.1
2

          
3
RUN echo "Downloading dbconvert studio"
4
ADD https://dbconvert.com/downloads/dbconvert_studio.zip /
5
COPY DBConvert-Studio.reg /
6
RUN powershell -Command "Write-Host 'Expanding dbconvert archive'; \
7
    Expand-Archive dbconvert_studio.zip; \
8
    Write-Host 'Installing dbconvert'; \
9
    Start-Process msiexec -ArgumentList '/i', 'C:\dbconvert_studio\dbconvert_studio_x64\DbConvertStudioSetup_x64.msi', '/quiet', '/norestart' -NoNewWindow -Wait; \
10
    Start-Process reg import DBConvert-Studio.reg; \
11
    Remove-Item -Path c:\dbconvert* -recurse -force; \
12
    Set-Location -Path 'C:\Program Files\DBConvert\DBConvert Studio x64';"
13
CMD ["powershell"]



Let’s dive deeper into what the Dockerfile actually does.

  • The first FROM line pulls the Insider Windows Server Core image.
  • The next RUN simply displays the status of the following ADD command. It downloads the installation zip package directly to our new image.
  • The COPY DBConvert-Studio. reg/ command copies the DBConvert registration file info to the root of the image. We will use it later to remove all restrictions on the DBConvert studio unregistered copy of the. (See the reg import command, which will appear later.)

Let’s take a look at the rest of the PowerShell commands combined into the following RUN command.

  • The Write-Host command displays the current status of the operation.
  • Expand-Archive—extracts the contents of the newly downloaded zip archive to the root directory of our image.
  • The Start-Process msiexec command installs the unpacked archive.
  • The next Start-Process reg command imports the registration file’s contents into our docker image’s Windows registry.
  • Remove-Item removes all unnecessary intermediary files from the final image.
  • Set-Location sets the specified location as a working directory.
  • The CMD [“powershell”] specifies what command to run within the container. In fact, we can call straight CMD [“DBConvert.exe”, “/ Session:”, “mysql2mysql”], but each time it may be a different session configuration file. Therefore, it is better to bind the directory on the host to the directory inside the container with the — volume (-v) flag.

Building Docker Image. Starting Container.

Launch the following command in the terminal to build your Docker image.

XML
 




x


 
1
docker build -t slotix/dbconvert-studio .



The next command, docker run, starts a container from the newly created DBConvert Studio image.

XML
 




xxxxxxxxxx
1


 
1
docker run --name studio -it --rm -v "c:\dbconvert-docker\studio\workSettings:C:\PROGRAM FILES\DBCONVERT\DBConvert Studio x64\workSettings" slotix/dbconvert-studio:latest DBConvert.exe /Session:"my2my_copy"



Containers are immutable by design. This means that the container will not be changed during its life cycle: no updates, no patches, no configuration changes.

When starting DBConvert studio from the command line, you need to pass in a ready-made session file that includes the configured database connections involved in the migration and some other parameters.

-v flag mounts c:\dbconvert-docker\studio\workSettings directory on the host machine into the folder C:\PROGRAM FILES\DBCONVERT\DBConvert Studio x64\workSettings inside the running container.

  • This way we can feed DBConvert Studio with jobs located outside of the container.
  • Another advantage of directory binding is that it works and vice versa. When a process completes, a log file is generated. It appears both inside the container directory and on the host computer.

Host OS communicating with the Docker Container

Check out the GitHub repository with the Dockerfile from this article here! 

Conclusion

  • Typically, the core business logic of a legacy monolithic application is tightly coupled to its GUI.
  • Legacy applications may not scale well enough to meet new customer needs, resulting in decreased performance and increased customer frustration.
  • Developers often get stuck in old code when there are so many exciting new technologies available to innovate.

The good news is that moving from a legacy desktop application to a microservice architecture stops the monolithic nightmare. Dividing a monolithic application into subsystems that can be scaled, developed, and deployed individually is your entry point into the microservices realm. If there is a requirement to run multiple copies of a single application, Docker is a perfect choice for packaging Windows applications.

This is why we ourselves adopted this concept when migrating existing Windows-based DBConvert products to the cloud infrastructure.

Docker (software) application Cloud computing Build (game engine) Desktop (word processor)

Published at DZone with permission of Dmitry Narizhnykh. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Manage Microservices With Docker Compose
  • 5 Simple Tips to Keep Dockerized Apps Secure
  • Top 10 Open Source Projects for SREs and DevOps
  • Build and Deploy a Flask Application Using Docker

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!