Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Linux Administration - Second Edition

You're reading from  Mastering Linux Administration - Second Edition

Product type Book
Published in Mar 2024
Publisher Packt
ISBN-13 9781837630691
Pages 764 pages
Edition 2nd Edition
Languages
Authors (2):
Alexandru Calcatinge Alexandru Calcatinge
Profile icon Alexandru Calcatinge
Julian Balog Julian Balog
Profile icon Julian Balog
View More author details

Table of Contents (24) Chapters

Preface 1. Part 1:Basic Linux Administration
2. Chapter 1: Installing Linux 3. Chapter 2: The Linux Shell and Filesystem 4. Chapter 3: Linux Software Management 5. Chapter 4: Managing Users and Groups 6. Chapter 5: Working with Processes, Daemons, and Signals 7. Part 2:Advanced Linux Administration
8. Chapter 6: Working with Disks and Filesystems 9. Chapter 7: Networking with Linux 10. Chapter 8: Linux Shell Scripting 11. Chapter 9: Securing Linux 12. Chapter 10: Disaster Recovery, Diagnostics, and Troubleshooting 13. Part 3:Server Administration
14. Chapter 11: Working with Virtual Machines 15. Chapter 12: Managing Containers with Docker 16. Chapter 13: Configuring Linux Servers 17. Part 4:Cloud Administration
18. Chapter 14: Short Introduction to Cloud Computing 19. Chapter 15: Deploying to the Cloud with AWS and Azure 20. Chapter 16: Deploying Applications with Kubernetes 21. Chapter 17: Infrastructure and Automation with Ansible 22. Index 23. Other Books You May Enjoy

Managing Containers with Docker

In this chapter, you will learn about one of the most well-known tools for creating and managing containers – Docker. The topics in this chapter will prepare you for the future of Linux, as it is the foundation of every modern cloud technology. If you wish to remain up to date in a constantly changing landscape, this chapter will be the essential starting point for your journey.

In this chapter, we’re going to cover the following main topics:

  • Understanding Linux containers
  • Working with Docker
  • Working with Dockerfiles
  • Deploying a containerized application with Docker

Technical requirements

No specific technical requirements are needed, just a working installation of Linux on your system. Both Ubuntu/Debian and Fedora/RHEL are equally suitable for this chapter’s exercises. We will use Debian GNU/Linux 12 for most of our examples, but where appropriate, we will discuss the specifics of Fedora Linux installation and use.

Understanding Linux containers

As we have demonstrated in the previous chapter, there are two main types of virtualization: virtual machine (VM)-based and container-based. We discussed VM-based virtualization in the previous chapter, and now it is time to explain what containers are. At a very basic, conceptual level, containers are similar to VMs. They have similar purposes – allowing an isolated environment to run – but they are different in so many ways that they can hardly be called similar. Let’s compare these two concepts in more detail.

Comparing containers and VMs

As you already know, a VM emulates the machine’s hardware and uses it as if there were several machines available. By comparison, containers do not replicate the physical machine’s hardware; they do not emulate anything.

A container shares the base OS kernel with shared libraries and binaries needed for certain applications to run. The applications are contained inside the...

Working with Docker

We will use Debian GNU/Linux 12 for this section’s exercises, installed on a VM with 2 vCPUs and 2 GB of RAM as a host. But before we start installing Docker, let’s go into a little detail about how Docker, as an entity, operates, to help us identify which version to choose for our use case.

Which Docker version to choose?

In order for the business to be viable, the corporation behind Docker (the Docker corporation) offers a series of products, all revolving around their primary product, Docker. In the past, it had two different products available, the Docker Community Edition (CE) and the Docker Enterprise Edition (EE). Out of these two, only the EE version was responsible for the revenue of Docker.

Recently, the portfolio evolved to different products and offerings, such as Docker Personal, Docker Pro, Docker Team, and Docker Business. Among those, only Docker Personal is free to use; the other three products are subscription-based. Docker...

Working with Dockerfiles

Before starting to work with Dockerfiles, let’s see what a Dockerfile is. It is a text file that consists of instructions defined by the user for Docker to execute, and respecting some basic structure, such as the following:

INSTRUCTION arguments

The Dockerfile is mainly used for creating new container images. This file is used by Docker to automatically build images based on the information the user provides inside the file. There are some keywords that define a Dockerfile. Those keywords, which are referred to as instructions, are as follows:

  • FROM: This must be the first instruction inside a Dockerfile as it tells Docker what the image is that you build upon
  • LABEL: This instruction adds some more information, such as a description, or anything that could help describe the new image you are creating; the use of such instructions needs to be limited
  • RUN: This is the instruction that offers direct interaction with the image, the place...

Deploying a containerized application with Docker

So far, we have shown you how to use Docker and how to manage containers. Docker is so much more than that, but this is enough to get you started and make you want to learn more. Docker is a great tool for developers as it offers a streamlined way to deploy applications by removing the necessity to replicate development environments. In the next section, we will show you how to deploy a simple website using Docker.

Deploying a website using Docker

To deploy a website using Docker, follow these steps:

  1. We will use a free website template randomly downloaded from the internet (the download link is https://www.free-css.com/free-css-templates/page262/focus). We will copy the download location from the website and download the file inside our home directory using the wget utility:
    wget https://www.free-css.com/assets/files/free-css-templates/download/page262/focus.zip
  2. The new file is a compressed ZIP file, so we will have...

Summary

In this chapter, we emphasized the importance of containerization. We showed you what containers are, how they work, and why they are so important. Containers are the foundation of the modern DevOps revolution, and you are now ready to use them. We also taught you about Docker, the basic commands for sleek use. You are now ready to start the cloud journey. Virtualization and container technologies are at the heart of cloud and server technologies.

In the next chapter, we will show you how to install and configure different Linux-based servers, such as web servers, DNS servers, DHCP servers, and mail servers.

Questions

Here’s a brief quiz about some of the essential concepts that were covered in this chapter:

  1. What is the major difference between containers and VMs?

    Hint: Revisit Figure 12.1.

  2. How does container technology work?
  3. What are the two major components of Docker architecture?
  4. Which Docker command shows the running containers?
  5. Which command is used for container network management?

    Hint: See the docker network command’s help.

Further reading

For more information on the topics covered in this chapter, you can refer to the following Packt titles:

  • Docker Quick Start Guide, Earl Waud
  • Mastering Docker – Fourth Edition, Russ McKendrick
  • Containerization with LXC, Konstantin Ivanov
  • A Developer’s Essential Guide to Docker Compose, Emmanouil Gkatziouras
lock icon The rest of the chapter is locked
You have been reading a chapter from
Mastering Linux Administration - Second Edition
Published in: Mar 2024 Publisher: Packt ISBN-13: 9781837630691
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}