Book Image

Learn Docker - Fundamentals of Docker 19.x - Second Edition

By : Dr. Gabriel N. Schenker
Book Image

Learn Docker - Fundamentals of Docker 19.x - Second Edition

By: Dr. Gabriel N. Schenker

Overview of this book

Containers enable you to package an application with all the components it needs, such as libraries and other dependencies, and ship it as one package. Docker containers have revolutionized the software supply chain in both small and large enterprises. Starting with an introduction to Docker fundamentals and setting up an environment to work with it, you’ll delve into concepts such as Docker containers, Docker images, and Docker Compose. As you progress, the book will help you explore deployment, orchestration, networking, and security. Finally, you’ll get to grips with Docker functionalities on public clouds such as Amazon Web Services (AWS), Azure, and Google Cloud Platform (GCP), and learn about Docker Enterprise Edition features. Additionally, you’ll also discover the benefits of increased security with the use of containers. By the end of this Docker book, you’ll be able to build, ship, and run a containerized, highly distributed application on Docker Swarm or Kubernetes, running on-premises or in the cloud.
Table of Contents (25 chapters)
1
Section 1: Motivation and Getting Started
4
Section 2: Containerization, from Beginner to Black Belt
11
Section 3: Orchestration Fundamentals and Docker Swarm
18
Section 4: Docker, Kubernetes, and the Cloud

Executing simple admin tasks in a container

Let's assume you need to strip all leading whitespaces from a file and you found the following handy Perl script to do exactly that:

$ cat sample.txt | perl -lpe 's/^\s*//'

As it turns out, you don't have Perl installed on your working machine. What can you do? Install Perl on the machine? Well, that would certainly be an option, and it's exactly what most developers or system admins do. But wait a second, you already have Docker installed on your machine. Can't we use Docker to circumvent the need to install Perl? Yes, we can. This is how we're going to do it:

  1. Create a folder, ch07/simple-task, and navigate to it:
$ mkdir -p ~/fod/ch07/simple-task && cd ~/fod/ch07/simple-task
  1. Open VS Code from within this folder:
$ code .
  1. In this folder, create a sample.txt file with...