Book Image

Learning Docker

By : Pethuru Raj, Jeeva S. Chelladhurai, Vinod Singh, Vinod kumar Singh, Jeeva Chelladhurai, Pethuru Raj Chelliah
Book Image

Learning Docker

By: Pethuru Raj, Jeeva S. Chelladhurai, Vinod Singh, Vinod kumar Singh, Jeeva Chelladhurai, Pethuru Raj Chelliah

Overview of this book

Table of Contents (18 chapters)
Learning Docker
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

We have been fiddling with virtualization techniques and tools for quite a long time now in order to establish the much-demanded software portability. The inhibiting dependency factor between software and hardware needs to be decimated by leveraging virtualization, a kind of beneficial abstraction, through an additional layer of indirection. The idea is to run any software on any hardware. This is achieved by creating multiple virtual machines (VMs) out of a single physical server, with each VM having its own operating system (OS). Through this isolation, which is enacted through automated tools and controlled resource sharing, heterogeneous applications are accommodated in a physical machine.

With virtualization, IT infrastructures become open, programmable, remotely monitorable, manageable, and maintainable. Business workloads can be hosted in appropriately-sized virtual machines and delivered to the outside world, ensuring broader and more frequent utilization. On the other hand, for high-performance applications, virtual machines across multiple physical machines can be readily identified and rapidly combined to guarantee any kind of high-performance requirement.

The virtualization paradigm has its own drawbacks. Because of the verbosity and bloatedness (every VM carries its own operating system), VM provisioning typically takes a while, the performance goes down due to excessive usage of computational resources, and so on. Furthermore, the growing need for portability is not fully met by virtualization. Hypervisor software from different vendors comes in the way of ensuring application portability. Differences in the OS and application distributions, versions, editions, and patches hinder smooth portability. Computer virtualization has flourished, whereas the other, closely associated concepts of network and storage virtualization are just taking off. Building distributed applications through VM interactions invites and involves some practical difficulties.

Let's move on to containerization. All of these barriers contribute to the unprecedented success of the idea of containerization. A container generally contains an application, and all of the application's libraries, binaries, and other dependencies are stuffed together to be presented as a comprehensive, yet compact, entity for the outside world. Containers are exceptionally lightweight, highly portable, easily and quickly provisionable, and so on. Docker containers achieve native system performance. The greatly articulated DevOps goal gets fully fulfilled through application containers. As best practice, it is recommended that every container hosts one application or service.

The popular Docker containerization platform has come up with an enabling engine to simplify and accelerate the life cycle management of containers. There are industry-strength and openly automated tools made freely available to facilitate the needs of container networking and orchestration. Therefore , producing and sustaining business-critical distributed applications is becoming easy. Business workloads are methodically containerized to be easily taken to cloud environments, and they are exposed for container crafters and composers to bring forth cloud-based software solutions and services. Precisely speaking, containers are turning out to be the most featured, favored, and fine-tuned runtime environment for IT and business services.

This book is meticulously designed and developed in order to empower developers, cloud architects, business managers, and strategists with all the right and relevant information on the Docker platform and its capacity to power up mission-critical, composite, and distributed applications across industry verticals.

What this book covers

Chapter 1, Getting Started with Docker, talks about the Docker platform and how it simplifies and speeds up the process of realizing containerized workloads to be readily deployed and run on a variety of platforms. This chapter also has step-by-step details on installing the Docker engine, downloading a Docker image from the centralized Docker Hub, creating a Docker container out of that image, and troubleshooting the Docker container.

Chapter 2, Handling Docker Containers, is primarily meant to expound the commands required to manage Docker images and containers. This chapter provides the basic Docker terminologies needed to understand the output of Docker commands. Other details covered here include starting an interactive session inside a container, managing your images, running containers, and tracking changes inside containers.

Chapter 3, Building Images, introduces Docker's integrated image building system. The other important topics covered in this chapter include a quick overview of a Dockerfile's syntax and a bit of theory on how Docker stores images.

Chapter 4, Publishing Images, focuses on publishing images on the centralized Docker Hub and how to get the most out of the Docker Hub. The other important contents in the chapter include greater details about the Docker Hub, how to push images to the Docker Hub, the automatic building of images, creating organizations on Docker Hub, and finally private repositories.

Chapter 5, Running Your Private Docker Infrastructure, explains how corporates can set up their own private repositories. Due to certain reasons, corporates may not want to host specific Docker images in publicly-available image repositories, such as the Docker Hub. Here, the need for their own private repository to keep up those images arises. This chapter has all of the information required to set up and sustain private repositories.

Chapter 6, Running Services in a Container, illustrates how a web application can be run inside a Docker container as a service, and how to expose the service for the outside world to find and access it. How the appropriate Dockerfile gets developed to simplify this task is also described in detail.

Chapter 7, Sharing Data with Containers, shows you how to use Docker's volumes feature to share data between the Docker host and its containers. The other topics covered here are how to share data between containers, the common use cases, and the typical pitfalls to avoid.

Chapter 8, Orchestrating Containers, focuses on orchestrating multiple containers towards composite, containerized workloads. It is a well-known truth that orchestration plays a major role in producing composite applications. This chapter includes some information about orchestration and the toolset made available for enabling the process of orchestration. Finally, you will find a well-orchestrated example of how containers can be orchestrated to bring forth highly reusable and business-aware containers.

Chapter 9, Testing with Docker, focuses on testing your code inside Docker images. In this chapter, you find out how to run the tests inside an ad hoc Docker image. Finally, you come across details of how to integrate Docker testing into a continuous integration server, such as Jenkins.

Chapter 10, Debugging Containers, teaches you how to debug applications running inside containers. Also, the details regarding how Docker ensures that processes running inside containers are isolated from the outside world are covered. Furthermore, descriptions of the usage of the nsenter and nsinit tools for effective debugging are included.

Chapter 11, Securing Docker Containers, is crafted to explain the brewing security and privacy challenges and concerns, and how they are addressed through the liberal usage of competent standards, technologies, and tools. This chapter inscribes the mechanism on dropping user privileges inside an image. There is also a brief introduction on how the security capabilities introduced in SELinux come in handy when securing Docker containers.

What you need for this book

The Docker platform requires a 64-bit hardware system to run on. Docker applications have been developed on Ubuntu 14.04 for this book, but this does not mean that the Docker platform cannot run on other Linux distributions, such as Redhat, CentOS, CoreOS, and so on. However, the Linux kernel version must be 3.10 or above.

Who this book is for

If you are an application developer who wants to learn about Docker in order to utilize its features for application deployment, then this book is for you. No prior knowledge of Docker is required.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "If the docker service is running, then this command will print the status as start/running, along with its process ID."

A block of code is set as follows:

FROM busybox:latest
CMD echo Hello World!!

Any command-line input or output is written as follows:

$ sudo docker tag 224affbf9a65localhost:5000/vinoddandy/dockerfileimageforhub

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Select the Docker option, which is in the drop-down menu, and then click on Launch Now."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.