Docker Containers: Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic, 1st edition

Published by Pearson (December 1, 2015) © 2016

  • Christopher Negus

eTextbook

$37.99

  • Available for purchase from all major ebook resellers, including InformIT.com.
  • To request a review copy, click on the "Request a Review Copy" button.
$31.99

  • A print text (hardcover or paperback) 
  • Free shipping
  • Also available for purchase as an ebook from all major ebook resellers, including InformIT.com
Negus begins by explaining how containers can overcome development, administration, and security problems that virtualization hasn't solved. He reviews the current state of containerization and Docker project, assesses Docker alternatives, and helps you decide whether Docker is right for your application. Next, he teaches Docker through a series of step-by-step demonstrations built on the open source Fedora distribution of Linux.
  • Walks through installing Docker, setting up a local registry, and creating Docker images and containers
  • Teaches to effectively manage and troubleshoot Docker containers on both local and remote systems
  • Shows how to orchestrate multiple Docker containers to form more complex applications

What is a VitalSource eTextbook?

The full text downloaded to your computer.

With VitalSource eTextbooks you can:

  • search for key concepts, words and phrases
  • make highlights and notes as you study
  • share your notes with friends

eTextbooks are downloaded to your computer and accessible either offline through the Bookshelf (available as a free download), available online and also via the iPad and Android apps.

Upon purchase, you'll gain instant access.

Preface     xv
Acknowledgments     xxi
About the Author     xxiii


Part I: Getting Going with Containers     1


Chapter 1: Containerizing Applications with Docker     3
Understanding Pros and Cons of Containerizing Applications     4
     ...An Application Running Directly on a Host Computer     4
     ...An Application Running Directly within a Virtual Machine     5
     Understanding the Upside of Containers     5
     Understanding Challenges of Containerizing Applications     7
Understanding What Makes Up Docker     8
     The Docker Project     8
     The Docker Hub Registry     9
     Docker Images and Containers     10
     The docker Command     11
Approaching Containers     13
Summary     14


Chapter 2: Setting Up a Container Run-Time Environment     17
Configuring a Standard Linux System for Docker     18
     Configuring Ubuntu for Docker     18
     Configuring Fedora for Docker     21
     Configuring Red Hat Enterprise Linux for Docker     25
     Configuring Other Operating Systems for Docker     27
Configuring a Container-Style Linux System for Docker     29
     Configuring an Atomic Host for Docker     29
     Configuring CoreOS for Docker     32
Summary     34


Chapter 3: Setting Up a Private Docker Registry     35
Getting and Starting a Private Docker Registry     36
     Setting Up a Docker Registry in Fedora     37
     Setting Up a Docker Registry in Ubuntu     40
Configuring a Private Docker Registry     43
     Configuring the docker-registry Package     43
     Configuring the registry Container     46
Understanding the Docker Image Namespace     46
Summary     48


Part II: Working with Individual Containers     49


Chapter 4: Running Container Images     51
Running Container Images Interactively     54
     Starting an Interactive Bash Shell     54
     Playing Some Character-Based Games     56
     Running Administrative Commands Inside a Container     57
Running Containerized Services     59
     Running a Containerized Web Server     59
     Limiting Resources When Running Services in Containers     62
Running Privileged Containers     63
Summary     64


Chapter 5: Finding, Pulling, Saving, and Loading Container Images     65
Searching for Images     66
     Searching for Images with the docker Command     66
     Searching for Images on Docker Hub     69
     Searching Other Repositories for Images     70
Pulling Images from Registries     73
Saving and Loading Images     76
Summary     77


Chapter 6: Tagging Images     79
Assigning Names to Images     80
Assigning Tags to Images     81
Assigning Repository Names to Images     83
     Attaching a User Name to an Image     83
     Attaching a Repository Name to an Image     85
Summary     86


Chapter 7: Investigating Containers     87
Inspecting Images and Containers     88
Inspecting an Image     88
     Inspecting Base Images with docker inspect     89
     Inspecting Application Images with docker inspect     90
     Looking at the History of an Image     92
Inspecting Running Containers     92
     Start a Container to Inspect     93
     Inspect an Entire Container Configuration     94
     Inspect Individual Container Attributes     99
Finding More Ways to Look into Containers     103
     Using docker top to See Container Processes     103
     Using docker attach to Interact with a Service Inside a Container     104
     Using docker exec to Start a New Process in a Running Container     105
     Using docker logs to See Container Process Output     106
     Using docker diff to See How a Container Has Changed     106
     Using docker cp to Copy Files from a Container     107
Summary     107


Chapter 8: Starting, Stopping, and Restarting Containers     109
Stopping and Starting a Container     109
     Stopping and Starting a Detached Container     110
     Starting and Stopping an Interactive Container     112
Restarting a Container     113
Sending Signals to a Container     114
Pausing and Unpausing Containers     115
Waiting for a Container’s Exit Code     116
Renaming a Container     117
Creating a Container     117
Summary     118


Chapter 9: Configuring Container Storage     121
Managing Storage for a Container     122
     Using Volumes from the Host     122
     Data Volume Container     123
     Write-Protecting a Bind Mount     124
     Mounting Devices     125
     Mounting Sockets     125
Storage Strategies for the Docker Host     127
     Attaching External Storage to a Docker Host     128
Summary     130


Chapter 10: Configuring Container Networking     133
Expose Ports to Other Containers     134
Map Ports Outside the Host     136
     Map a Port from Linked Containers     136
     Connect Containers on Different Hosts     138
Alternatives to the docker0 Bridge     139
     Changing Network Mode for a Container     140
     Examining Network Options     140
Changing the Docker Network Bridge     142
Summary     143


Chapter 11: Cleaning Up Containers     145
Making Space for Images and Containers     146
Removing Images     146
     Removing Individual Images     147
     Removing Multiple Images     148
Removing Containers     150
     Removing Individual Containers     150
     Removing Multiple Containers     152
Cleaning Up and Saving Containers     153
     Cleaning Up and Saving an Ubuntu Container     153
     Cleaning Up and Saving a Fedora Container     154
Summary     154


Chapter 12: Building Docker Images     157
Doing a Simple docker build     158
Setting a Command to Execute from a Dockerfile     161
     Using the CMD Instruction     161
     Using the ENTRYPOINT Instruction     162
     Using the RUN Instruction     163
     Adding Files to an Image from a Dockerfile     164
Exposing Ports from an Image within a Dockerfile     165
Assigning Environment Variables in a Dockerfile     166
Assigning Labels in a Dockerfile     167
Using Other docker build Command Options     168
Tips for Building Containers     169
     Clean Up the Image     169
     Keep Build Directory Small     169
     Keep Containers Simple     170
     Manage How Caching Is Done     170
Summary     171


Part III: Running Containers in Cloud Environments     173


Chapter 13: Using Super Privileged Containers     175
Using Super Privileged Containers in Atomic Host     176
Understanding Super Privileged Containers     176
     Opening Privileges to the Host     177
     Accessing the Host Process Table     177
     Accessing Host Network Interfaces     178
     Accessing Host Inter-Process Communications     179
     Accessing Host File Systems     179
Preparing to Use Super Privileged Containers     180
Using the atomic Command     180
     Installing an SPC Image with atomic     182
     Getting Information about an SPC Image with atomic     182
     Running an SPC Image with atomic     183
     Stopping and Restarting an SPC with atomic     184
     Updating an SPC Image     184
     Uninstalling an SPC Image     185
Trying Some SPCs     185
     Running the RHEL Tools SPC     186
     Running the Logging (rsyslog) SPC     187
     Running the System Monitor (sadc) SPC     189
Summary     191


Chapter 14: Managing Containers in the Cloud with Cockpit     193
Understanding Cockpit     194
Starting with Cockpit     198
Adding Servers into Cockpit     199
Working with Containers from Cockpit     201
     Adding Container Images to Cockpit     201
     Running Images from Cockpit     201
Working with Network Interfaces from Cockpit     204
Configuring Storage from Cockpit     207
Doing Other Administrative Tasks in Cockpit     208
     Managing Administrator Accounts in Cockpit     208
     Open a Terminal in Cockpit     209
Summary     210


Part IV: Managing Multiple Containers     211


Chapter 15: Orchestrating Containers with Kubernetes     213
Understanding Kubernetes     214
Starting with Kubernetes     216
Setting Up an All-in-One Kubernetes Configuration     218
     Installing and Starting Up Kubernetes     218
     Starting Up a Pod in Kubernetes     220
     Working with Kubernetes     223
Summary     224


Chapter 16: Creating a Kubernetes Cluster     225
Understanding Advanced Kubernetes Features     226
Setting Up a Kubernetes Cluster     226
     Step 1: Install Linux     227
     Step 2: Set Up Kubernetes Master     227
     Step 3: Set Up Kubernetes Nodes     230
     Step 4: Set Up Networking with Flannel     231
Starting Up Pods in a Kubernetes Cluster     233
Deleting Replication Controllers, Services, and Pods     237
Summary     238


Part V: Developing Containers     239


Chapter 17: Developing Docker Containers     241
Setting Up for Container Development     241
     Choosing a Container Development Environment for Red Hat Systems     242
     Container Development Environments from Docker     246
Using Good Development Practices     247
     Gathering or Excluding Files for a Build     248
     Taking Advantage of Layers     249
     Managing Software Packages in a Build     250
     Learning More about Building Containers     251
Summary     252


Chapter 18: Exploring Sample Dockerfile Files     253
Examining Dockerfiles for Official Docker Images     254
     Viewing a CentOS Dockerfile     254
     Viewing a Busybox Dockerfile     257
Examining Dockerfiles from Open Source Projects     258
     Viewing a WordPress Dockerfile     258
     Viewing the MySQL Dockerfile     260
Examining Dockerfiles for Desktop and Personal Use     263
     Viewing a Chrome Dockerfile     263
     Viewing a Firefox Dockerfile     267
Summary     270


Index     273

Christopher Negus is a bestselling author of Linux books, a certified Linux instructor and examiner, Red Hat Certified Architect, and principal technical writer for Red Hat. At the moment, projects Chris is working on include Red Hat OpenStack Platform High Availability, Red Hat Enterprise Linux Atomic Enterprise, Kubernetes, and Linux Containers in Docker format.


As an author, Chris has written dozens of books about Linux and open source software. His Linux Bible, Ninth Edition, released in 2015, is consistently among the top-selling Linux books today. During the dotcom days, Chris’s Red Hat Linux Bible sold more than 250,000 copies in eight editions and was twice voted best Linux book of the year. Other books authored or coauthored by Chris include the Linux Toolbox series, Linux Toys series, Fedora and Red Hat Enterprise Linux Bible series, and Linux Troubleshooting Bible with Wiley Publishing.

With Prentice Hall, Chris helped produce the Negus Software Solution Series. For that series, Chris wrote Live Linux CDs and coauthored The Official Damn Small Linux Book. That series also includes books on web development, Google Apps, and virtualization.


Chris joined Red Hat in 2008 as an RHCE instructor. For that role, he became a Red Hat Certified Instructor (RHCI) and Red Hat Certified Examiner (RHCX). In 2014, Chris became a Red Hat Certified Architect (RHCA), with certifications in Virtualization Administration, Deployment and Systems Management, Cluster and Storage Management, and Server Hardening. In 2011, Chris shifted from his Linux instructor role back to being a full-time writer for Red Hat, which he continues to do today.

Early in his career, Chris worked at UNIX System Laboratories and AT&T Bell Labs with the organizations that produced the UNIX operating system. During that time, Chris wrote the first official UNIX System V Desktop system manual and cowrote the Guide to the UNIX Desktop. For eight years, Chris worked closely with developers of the UNIX system, from UNIX System V Release 2.0 through Release 4.2.

Need help? Get in touch

Video
Play
Privacy and cookies
By watching, you agree Pearson can share your viewership data for marketing and analytics for one year, revocable upon changing cookie preferences. Disabling cookies may affect video functionality. More info...

Pearson eTextbook: What’s on the inside just might surprise you

They say you can’t judge a book by its cover. It’s the same with your students. Meet each one right where they are with an engaging, interactive, personalized learning experience that goes beyond the textbook to fit any schedule, any budget, and any lifestyle.Â