Overview

The Practical Guide to Running Docker on Linux Systems or Cloud Environments

Whether on your laptop or a remote cloud, Docker can transform how you create, test, deploy, and manage your most critical applications. In Docker Containers, Christopher Negus helps you master Docker containerization from the ground up.

You’ll start out running a few Docker container images in Ubuntu, Fedora, RHEL, CoreOS, or Project Atomic. By the time you’ve finished, you’ll be deploying enterprise-quality, multi-container Kubernetes setups in modern Linux and cloud environments.

Writing for system administrators, software developers, and technology enthusiasts, Negus touches on every aspect of working with Docker: setting up containerized applications, working with both individual and multiple containers, running containers in cloud environments, and developing containers.

Teaching through realistic examples of desktop applications, system services, and games, Negus guides you through building and deploying your own Dockerized applications. As you build your expertise, you’ll also learn indispensable Docker best practices for building and integrating containers, managing Docker on a day-to-day basis, and much more:

• Understanding what Docker is and what you can do with it• Installing Docker on standard Linux or specialized container operating systems such as Atomic Host and CoreOS• Setting up a container runtime environment and private Docker Registry• Creating, running, and investigating Docker images and containers• Finding, pulling, saving, loading, and tagging container images• Pulling and pushing containers between local systems and Docker Registries• Integrating Docker containers with host networking and storage• Building containers with the docker build command and Dockerfile files• Minimizing space consumption and erasing unneeded containers• Accessing special host privileges from within a container• Orchestrating multiple containers into complex applications with Kubernetes• Using super privileged containers in cloud environments• Managing containers in the cloud with Cockpit• Getting started with Docker container development• Learning container build techniques from shared Dockerfiles

This book is part of the Pearson Content Update Program. As the technology changes, sections of this book will be updated or new sections will be added. The updates will be delivered to you via a free Web Edition of this book, which can be accessed with any Internet connection.

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

Chapter 7: Investigating Containers 87Inspecting Images and Containers 88Inspecting an Image 88 Inspecting Base Images with docker inspect 89 Inspecting Application Images with docker inspect 90 Looking at the History of an Image 92Inspecting Running Containers 92 Start a Container to Inspect 93 Inspect an Entire Container Configuration 94 Inspect Individual Container Attributes 99Finding 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 107Summary 107

Chapter 12: Building Docker Images 157Doing a Simple docker build 158Setting 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 164Exposing Ports from an Image within a Dockerfile 165Assigning Environment Variables in a Dockerfile 166Assigning Labels in a Dockerfile 167Using Other docker build Command Options 168Tips for Building Containers 169 Clean Up the Image 169 Keep Build Directory Small 169 Keep Containers Simple 170 Manage How Caching Is Done 170Summary 171

Chapter 17: Developing Docker Containers 241Setting Up for Container Development 241 Choosing a Container Development Environment for Red Hat Systems 242 Container Development Environments from Docker 246Using 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 251Summary 252