Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Containers for Developers Handbook
  • Table Of Contents Toc
Containers for Developers Handbook

Containers for Developers Handbook

By : Francisco Javier Ramírez Urea
5 (5)
close
close
Containers for Developers Handbook

Containers for Developers Handbook

5 (5)
By: Francisco Javier Ramírez Urea

Overview of this book

Developers are changing their deployment artifacts from application binaries to container images, giving rise to the need to build container-based apps as part of their new development workflow. Managing an app’s life cycle is complex and requires effort—this book will show you how to efficiently develop, share, and execute applications. You’ll learn how to automate the build and delivery process using CI/CD tools with containers as container orchestrators manage the complexity of running cluster-wide applications, creating infrastructure abstraction layers, while your applications run with high availability, resilience, and persistence. As you advance, you’ll develop, test, and debug applications on your desktop and get them ready to run in production with optimal security standards, using deployment patterns and monitoring tools to help identify common issues. You’ll also review deployment patterns that’ll enable you to solve common deployment problems, providing high availability, scalability, and security to your applications. Finally, you’ll explore different solutions to monitor, log, and instrument your applications as per open-source community standards. By the end of this book, you’ll be able to manage your app’s life cycle by implementing CI/CD workflows using containers to automate the building and delivery of its components.
Table of Contents (20 chapters)
close
close
1
Part 1:Key Concepts of Containers
7
Part 2:Container Orchestration
11
Part 3:Application Deployment
16
Part 4:Improving Applications’ Development Workflow

Labs

In this first chapter, we covered a lot of content, learning what containers are and how they fit into the modern microservices architecture.

In this lab, we will install a fully functional development environment for container-based applications. We will use Docker Desktop because it includes a container runtime, its client, and a minimal but fully functional Kubernetes orchestration solution.

We could use Docker Engine in Linux directly (the container runtime only, following the instructions at https://docs.docker.com/) for most labs but we will need to install a new tool for the Kubernetes labs, which requires a minimal Kubernetes cluster installation. Thus, even for just using the command line, we will use the Docker Desktop environment.

Important note

We will use a Kubernetes desktop environment to minimize CPU and memory requirements. There are even lighter Kubernetes cluster alternatives such as KinD or K3S, but these may require some customization. Of course, you can also use any cloud provider’s Kubernetes environment if you feel more comfortable doing so.

Installing Docker Desktop

This lab will guide you through the installation of Docker Desktop on your laptop or workstation and how to execute a test to verify that it works correctly.

Docker Desktop can be installed on Microsoft Windows 10, most of the common Linux flavors, and macOS (the arm64 and amd64 architectures are both supported). This lab will show you how to install this software on Windows 10, but I will use Windows and Linux interchangeably in other labs as they mostly work the same – we will review any differences between the platforms when required.

We will follow the simple steps documented at https://docs.docker.com/get-docker/. Docker Desktop can be deployed on Windows using Hyper-V or the newer Windows Subsystem for Linux 2 (WSL 2). This second option uses less compute and memory resources and is nicely integrated into Microsoft Windows, making it the preferred installation method, but note that WSL2 is required on your host before installing Docker Desktop. Please follow the instructions from Microsoft at https://learn.microsoft.com/en-us/windows/wsl/install before installing Docker Desktop. You can install any Linux distribution because the integration will be automatically included.

We will use the Ubuntu WSL distribution. It is available from the Microsoft Store and is simple to install:

Figure 1.9 – Ubuntu in the Microsoft Store

Figure 1.9 – Ubuntu in the Microsoft Store

During the installation, you will be prompted for username and password details for this Windows subsystem installation:

Figure 1.10 – After installing Ubuntu, you will have a fully functional Linux Terminal

Figure 1.10 – After installing Ubuntu, you will have a fully functional Linux Terminal

You can close this Ubuntu Terminal as the Docker Desktop integration will require you to open a new one once it has been configured.

Important note

You may need to execute some additional steps at https://docs.microsoft.com/windows/wsl/wsl2-kernel to update WSL2 if your operating system hasn’t been updated.

Now, let’s continue with the Docker Desktop installation:

  1. Download the installer from https://docs.docker.com/get-docker/:

Figure 1.11 – Docker Desktop download section

Figure 1.11 – Docker Desktop download section

  1. Once downloaded, execute the Docker Desktop Installer.exe binary. You will be asked to choose between Hyper-V or WSL2 backend virtualization; we will choose WSL2:
Figure 1.12 – Choosing the WSL2 integration for better performance

Figure 1.12 – Choosing the WSL2 integration for better performance

  1. After clicking Ok, the installation process will begin decompressing the required files (libraries, binaries, default configurations, and so on). This could take some time (1 to 3 minutes), depending on your host’s disk speed and compute resources:
Figure 1.13 – The installation process will take a while as the application files are decompressed and installed on your system

Figure 1.13 – The installation process will take a while as the application files are decompressed and installed on your system

  1. To finish the installation, we will be asked to log out and log in again because our user was added to new system groups (Docker) to enable access to the remote Docker daemon via operating system pipes (similar to Unix sockets):
Figure 1.14 – Docker Desktop has been successfully installed and we must log out

Figure 1.14 – Docker Desktop has been successfully installed and we must log out

  1. Once we log in, we can execute Docker Desktop using the newly added application icon. We can enable Docker Desktop execution on start, which could be very useful, but it may slow down your computer if you are short on resources. I recommend starting Docker Desktop only when you are going to use it.

    Once we’ve accepted the Docker Subscription license terms, Docker Desktop will start. This may take a minute:

Figure 1.15 – Docker Desktop is starting

Figure 1.15 – Docker Desktop is starting

You can skip the quick guide that will appear when Docker Desktop is running because we will learn more about this in the following chapters as we deep dive into building container images and container execution.

  1. We will get the following screen, showing us that Docker Desktop is ready:
Figure 1.16 – Docker Desktop main screen

Figure 1.16 – Docker Desktop main screen

  1. We need to enable WSL2 integration with our favorite Linux distribution:
Figure 1.17 – Enabling our previously installed Ubuntu using WSL2

Figure 1.17 – Enabling our previously installed Ubuntu using WSL2

  1. After this step, we are finally ready to work with Docker Desktop. Let’s open a terminal using our Ubuntu distribution, execute docker, and, after that, docker info:
Figure 1.18 – Executing some Docker commands just to verify container runtime integration

Figure 1.18 – Executing some Docker commands just to verify container runtime integration

As you can see, we have a fully functional Docker client command line associated with the Docker Desktop WSL2 server.

  1. We will end this lab by executing an Alpine container (a small Linux distribution), reviewing its process tree and the list of its root filesystem.

    We can execute docker run-ti alpine to download the Alpine image and execute a container using it:

Figure 1.19 – Creating a container and executing some commands inside before exiting

Figure 1.19 – Creating a container and executing some commands inside before exiting

  1. This container execution left changes in Docker Desktop; we can review the current images present in our container runtime:

Figure 1.20 – Docker Desktop – the Images view

Figure 1.20 – Docker Desktop – the Images view

  1. We can also review the container, which is already dead because we exited by simply executing exit inside its shell:
Figure 1.21 – Docker Desktop – the Containers view

Figure 1.21 – Docker Desktop – the Containers view

Now, Docker Desktop works and we are ready to work through the following labs using our WSL2 Ubuntu Linux distribution.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Containers for Developers Handbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon