Docker: Practical Guide for Developers and Devops Teams
- Length: 496 pages
- Edition: F
- Language: English
- Publisher: Rheinwerk Computing
- Publication Date: 2023-01-25
- ISBN-10: 1493223836
- ISBN-13: 9781493223831
- Sales Rank: #75540 (See Top 100 Books)
Learn the ins and outs of containerization in Docker with this practical guide! Begin by installing and setting up the platform. Then master the basics: get to know important terminology, understand how to run containers, and set up port redirecting and communication. You’ll learn to create custom images, work with commands, and use key containerization tools. Gain essential skills by following exercises that cover common tasks from packaging new applications and modernizing existing applications to handling security and operations.
- Get hands-on practice with Docker, from setup to orchestration
- Work with Dockerfiles, the docker compose command, GitLab, and Docker Hub
- Learn about project migration, security, Kubernetes, and more
- Consult and download practical code examples
Basics
Install Docker on Windows, macOS, or Linux. Then master the basic principles of working with the Docker platform: What are images? How do containers communicate with each other? Where do containers store data? You’ll get to know Dockerfile syntax, learn to upload images, work with the docker compose command, and much more.
Tools
Build containers with essential tools, including Alpine Linux; Apache and Ngnix web servers; MySQL/MariaDB, MongoDB, PostgreSQL, and Redis database servers; JavaScript, Java, and Python programming languages; and web applications such as WordPress and Joomla.
Hands-on Exercises
Develop modern web applications and transform existing projects with Docker by following step-by-step exercises. Use GitLab, Swarm, and Kubernetes to take your Docker projects to the next level. Round out your knowledge by configuring basic security mechanisms and setting up CI/CD pipelines.
Dear Reader Notes on Usage Table of Contents Preface Docker About This Book Brave New Docker World Part I Introduction 1 Hello World 1.1 Docker Quick Install 1.1.1 Windows 1.1.2 macOS 1.1.3 Linux 1.2 Apache with PHP 8 1.2.1 Dockerfile 1.3 Node.js 1.4 Python 2 Installation 2.1 Docker Variants 2.2 Version Numbers 2.3 Installation on Windows 2.4 Installation on macOS 2.5 Installation on Linux 2.5.1 Installation on Ubuntu 2.5.2 Installation on the Raspberry Pi Operating System 2.5.3 Installation on Red Hat Enterprise Linux 8 and Fedora 2.5.4 Other Installation Variants 2.5.5 Troubleshooting and Logging 2.5.6 Working without “sudo” 2.6 Rootless Docker 2.6.1 “newuidmap” and “newgidmap” 2.6.2 Using a System-Wide Rootless Docker Installation 2.6.3 Installing Rootless Docker 2.6.4 No “ping” 2.6.5 Local Docker Files 2.6.6 Problems with the Virtual File System Directory 3 Basic Principles 3.1 Basic Principles and Terminology 3.1.1 Images and Containers 3.1.2 Volumes 3.1.3 Services, Stacks, and Clusters 3.1.4 docker Command versus Docker Daemon (dockerd) 3.1.5 Linux versus Windows 3.1.6 Virtual Machines versus Containers 3.2 Running Containers 3.2.1 Status Information 3.2.2 Tidying Up 3.3 Using Containers Interactively 3.3.1 Network Connection 3.3.2 Containers versus Images Again 3.3.3 Running the Container Again via “docker start” 3.3.4 Custom Container Names 3.3.5 Running Other Processes in Parallel via docker exec 3.3.6 Tidying Up 3.4 Port Redirection 3.4.1 Connecting Container Ports to Local Ports 3.4.2 Problems with Port 80 3.4.3 Tidying Up 3.5 Data Storage in Volumes 3.5.1 Storing the Database in an Automatically Created Volume 3.5.2 Analyzing Volumes 3.5.3 Calling the MariaDB Client 3.5.4 A Look Inside the Container 3.5.5 Logging 3.5.6 Tidying Up 3.6 Named Volumes 3.6.1 Container Update without Data Loss 3.6.2 Tidying Up 3.7 Volumes in Custom Directories 3.7.1 Problems with Security-Enhanced Linux 3.7.2 Problems on Windows Hosts 3.7.3 Tidying Up 3.8 Communication between Containers 3.8.1 Setting Up a Private Docker Network 3.8.2 MariaDB 3.8.3 phpMyAdmin 3.8.4 WordPress 3.8.5 Stopping and Restarting Containers 3.8.6 Updates 3.8.7 Tidying Up 3.9 Administration of Docker 3.9.1 Determining Space Requirements of Images and Containers 3.9.2 Deleting Containers and Images 3.9.3 Managing Volumes 3.9.4 General Overview 3.9.5 Releasing Unused Space 4 Custom Docker Images (Dockerfiles) 4.1 Dockerfiles 4.1.1 Dockerfile Syntax 4.1.2 Introductory Example 4.1.3 Specifying the Source Image (“FROM”) 4.1.4 Adding Files (“ADD” versus “COPY”) 4.1.5 Container “start” Command (“CMD” and “ENTRYPOINT”) 4.1.6 Running Commands (RUN) 4.1.7 Volume Directories (VOLUME) 4.1.8 Creating and Testing an Image 4.1.9 Tidying Up 4.2 A Custom Web Server Image 4.2.1 Creating and Testing an Image 4.3 Uploading Images to Docker Hub 4.3.1 Login 4.3.2 “push” Command 4.3.3 Image Description 4.3.4 Image Tags 4.3.5 Deleting Uploaded Images 4.4 Setting Up a Pandoc and LaTeX Environment as an Image 4.4.1 Installation Work 4.4.2 Working Directory and Volume 4.4.3 Creating the Image 4.4.4 Running the Container 4.4.5 Troubleshooting 5 docker compose 5.1 docker-compose versus docker stack 5.2 Installing “docker-compose” 5.3 YAML Ain’t Markup Language Syntax 5.4 Hello Compose! 5.4.1 “docker compose” 5.4.2 “docker stack deploy” 5.4.3 Debugging 5.4.4 Interactive Use 5.5 The docker-compose.yml File 5.5.1 Image or Dockerfile? 5.5.2 Networks 5.5.3 Network Ports 5.5.4 Volumes 5.5.5 Named Volumes 5.5.6 Environment Variables 5.5.7 Command Execution 5.5.8 Restart Behavior 5.5.9 Deploy Settings 5.6 Passwords and Other Secrets 5.6.1 Sharing MariaDB/MySQL Passwords between Two Containers 5.6.2 Secure Exchange of Secrets 6 Tips, Tricks, and Internal Details 6.1 Visual Studio Code 6.1.1 Docker Extension 6.1.2 Remote Containers 6.2 Portainer 6.2.1 Tidying Up 6.3 Pull Limit in Docker Hub 6.3.1 Lots of Activity in Docker Hub 6.3.2 No Unlimited Access to Images 6.3.3 Bypassing the Limit 6.3.4 Using Alternative Registries 6.4 Using Different CPU Architectures 6.4.1 Working on ARM Computers 6.4.2 Running Containers of a Different Architecture 6.5 Starting Containers Automatically 6.5.1 Restart Behavior with docker compose 6.5.2 Automatically Starting Docker Containers on a Linux Server with systemd 6.5.3 A Separate Service File 6.5.4 Starting and Ending the Service 6.6 A Look Behind the Scenes 6.6.1 docker, dockerd, and containerd 6.6.2 The Overlay File System 6.6.3 The /var/lib/docker Directory 6.6.4 Process Management 6.6.5 Resource Management through Control Groups 6.6.6 Container Isolation through Namespaces 6.6.7 Why the docker Command Usually Requires Root Privileges 6.6.8 More “sudo” Convenience 6.6.9 Network Management 6.6.10 Windows (WSL2) 6.6.11 Limiting RAM Utilization through Docker and WSL2 6.6.12 macOS (Hypervisor and Virtualization Framework) 7 docker Command Reference 7.1 docker attach 7.2 docker build 7.3 docker commit 7.4 docker compose * 7.5 docker-compose config 7.6 docker-compose down 7.7 docker-compose events 7.8 docker-compose kill 7.9 docker-compose logs 7.10 docker-compose pause and docker compose unpause 7.11 docker-compose ps 7.12 docker-compose rm 7.13 docker-compose run 7.14 docker-compose start, docker-compose stop, and docker compose restart 7.15 docker-compose top 7.16 docker-compose up 7.17 docker container * 7.18 docker create 7.19 docker diff 7.20 docker events 7.21 docker exec 7.22 docker export 7.23 docker image * 7.24 docker images 7.25 docker import 7.26 docker info 7.27 docker inspect 7.28 docker kill 7.29 docker login and docker logout 7.30 docker logs 7.31 docker network * 7.32 docker node * 7.33 “docker pause” and “docker unpause” 7.34 “docker port” 7.35 docker ps 7.36 docker pull 7.37 docker push 7.38 docker rename 7.39 docker restart 7.40 docker rm and docker rmi 7.41 docker run 7.42 docker secret * 7.43 docker service * 7.44 docker stack * 7.45 docker start and docker stop 7.46 docker stats 7.47 docker swarm * 7.48 docker system * 7.49 docker tag 7.50 docker top 7.51 docker update 7.52 docker volume * 7.53 docker wait Part II Toolbox 8 Alpine Linux 8.1 Characteristics 8.1.1 Trying Out Alpine Linux 8.1.2 Shell 8.1.3 BusyBox 8.1.4 Init System and Logging 8.1.5 The “musl” Library 8.1.6 Documentation 8.1.7 Missing “root” Password 8.2 Package Management with “apk” 8.2.1 Package Sources 8.2.2 Packages and Their Files 9 Web Servers and Company 9.1 Apache HTTP Server 9.1.1 Using an Official Docker Image 9.1.2 Using a Custom Dockerfile 9.1.3 Using the Official Docker Image 9.2 Nginx 9.2.1 Usage with a Custom Dockerfile 9.3 Nginx as Reverse Proxy with SSL Certificates from Let’s Encrypt 9.3.1 Nginx Reverse Proxy 9.3.2 Creating the First Certificate 9.3.3 Application Programming Interface Server 9.3.4 Renewing Certificates 9.4 Node.js with Express 9.4.1 Express Framework 9.4.2 Docker Development Environment for Express 9.4.3 Docker Production Environment for Express 9.4.4 Debugging the Applications 9.5 HAProxy 9.5.1 Hello World! 9.6 Traefik Proxy 9.6.1 Installing and Configuring Traefik 9.6.2 Connecting Docker Services with Traefik 10 Database Systems 10.1 MySQL and MariaDB 10.1.1 Setting Up and Using MariaDB Containers Manually 10.1.2 Setting Up a MariaDB Service with “docker-compose” 10.1.3 Setting Up the Database during Initialization 10.1.4 Backups 10.1.5 Using a Custom Configuration File (my.cnf) 10.2 PostgreSQL 10.2.1 PostgreSQL and pgAdmin with “docker compose” 10.2.2 Backups with “docker compose” 10.3 MongoDB 10.3.1 Simple “docker compose” Setup with MongoDB 10.3.2 Database Access 10.3.3 MongoDB with Authentication 10.4 Redis 10.4.1 Redis Replication with “docker compose” 11 Programming Languages 11.1 JavaScript (Node.js) 11.1.1 Trying Out Node.js 11.1.2 “printheadlines”: Packaging Node.js Script as a Docker Image 11.2 Java 11.2.1 “printheadlines” Example 11.2.2 Resource Management 11.3 PHP: Hypertext Preprocessor 11.3.1 Official PHP Docker Images 11.3.2 PHP as a Command-Line Program 11.3.3 PHP with Web Servers (EXIF Example) 11.3.4 Dockerfile for the EXIF Example 11.3.5 docker-compose.yml for the EXIF Example 11.4 Ruby 11.4.1 “printheadlines” Example 11.5 Python 11.5.1 “printheadlines” Example 11.5.2 Packaging an Existing Python Application as a Docker Image 11.5.3 Sample Code 11.5.4 Localization and Character Sets in Python Programs 12 Web Applications and Content Management Systems 12.1 WordPress 12.1.1 Custom Docker Images 12.1.2 The “wp-cli” Command 12.1.3 Dealing with Passwords 12.1.4 Update 12.1.5 Backup 12.2 Nextcloud 12.2.1 Installation via “docker compose” 12.2.2 Creating Backups 12.3 Joomla Part III Exercises 13 A Modern Web Application 13.1 The Application 13.1.1 Technical Background 13.2 The Frontend: Vue.js 13.2.1 Vue.js Setup 13.2.2 Development and Production Image (Multistage Builds) 13.2.3 Implementation via docker-compose.override.yml 13.2.4 Bundling JavaScript Code with Webpack 13.2.5 Docker “ENTRYPOINT” Script for Node.js Modules 13.2.6 Source Code 13.2.7 The Main Vue.js Component 13.3 The API Server: Node.js Express 13.3.1 Stateless or Stateful? 13.3.2 Node.js Modules in the Development Environment 13.3.3 Accessing the Application Programming Interface 13.3.4 Source Code (server.js) 13.3.5 Source Code (routes.js) 13.4 The Mongo Database 13.5 The Session Storage: Redis 14 Grafana 14.1 Grafana-Docker Setup 14.1.1 Generating Data with Collectors (Telegraf) 14.1.2 Storing Data with InfluxDB 14.1.3 Visualizing Data with Grafana 14.2 Provisioning 14.3 A Customized Telegraf Image 14.3.1 Dashboard Customizations 15 Modernizing a Traditional Application 15.1 The Existing Application 15.2 Planning and Preparation 15.2.1 The Web Server 15.2.2 WordPress 15.2.3 WordPress Database Migration 15.2.4 Automatic Updates in WordPress 15.2.5 MariaDB 15.2.6 Node.js Server 15.2.7 The Map Application 15.2.8 Cron Jobs 15.2.9 Backups 15.3 The Development Environment 15.4 Production Environment and Migration 15.5 Updates 15.6 Tips for the Transition 15.7 Results 16 GitLab 16.1 GitLab Quick Start 16.2 GitLab Web Installation 16.3 HTTPS via a Reverse Proxy Setup 16.4 Email Dispatch 16.4.1 Sending Emails with Your Own Exim Mail Server 16.4.2 Integration into the GitLab Configuration 16.5 Secure Shell Access 16.6 Volumes and Backup 16.6.1 Backing Up GitLab Application Files 16.6.2 Restore 16.7 Custom Docker Registry for GitLab 16.8 The Complete docker-compose File 16.9 Using GitLab 16.9.1 User 16.9.2 Projects 16.9.3 Wiki 16.9.4 Tickets and Issues 16.10 GitLab Runner 16.10.1 Installation 16.10.2 The Shell Executor 16.10.3 The Docker Executor 16.10.4 The Kubernetes Executor 16.11 Mattermost 16.11.1 Connecting to GitLab 17 Continuous Integration and Continuous Delivery 17.1 The dockerbuch.info Website with gohugo.io 17.1.1 Running Hugo as a Docker Container 17.1.2 Hugo Quick Start 17.2 Docker Images for the CI/CD Pipeline 17.2.1 Web Server Docker Image 17.2.2 Link Checker 17.2.3 HTML Validator 17.3 The CI/CD Pipeline 17.3.1 CI/CD with the GitLab Shell Runner 17.3.2 Testing the Pipeline 17.3.3 CI with the GitLab Docker Runner 17.3.4 CI/CD with Kubernetes in the Google Cloud 18 Security 18.1 Software Installation 18.2 Origin of Docker Images 18.2.1 External Registries 18.3 "root" in Docker Images 18.3.1 Nginx Web Server without "root" Privileges 18.4 The Docker Daemon 18.4.1 Rootless Docker 18.5 User Namespaces 18.5.1 Functionality 18.6 Control Groups 18.7 Secure Computing Mode 18.8 AppArmor Security Profiles 18.8.1 AppArmor Profile for Docker 18.8.2 Custom AppArmor Rules 19 Swarm and Amazon Elastic Container Service 19.1 Swarm versus Kubernetes 19.2 Docker Swarm 19.2.1 Swarm Quick Start 19.2.2 “Hello World” in the Swarm 19.3 Docker Swarm in the Hetzner Cloud 19.3.1 CLI Installation and Configuration with “hcloud” 19.3.2 Installing Docker with “cloud-init” 19.3.3 Creating Cloud Instances 19.3.4 Launching the Diary App in Docker Swarm 19.3.5 Secure Sockets Layer Certificates 19.3.6 Simulating a Server Failure 19.3.7 Security 19.4 Amazon Elastic Container Service 19.4.1 Quick Start: Launching a Container in the AWS Cloud 19.4.2 Amazon Elastic Container Service with “docker compose” 20 Kubernetes 20.1 Minikube 20.1.1 Autocompletion for “kubectl” 20.1.2 The First Deployment in Minikube 20.1.3 Object Configuration in Files 20.1.4 Kubernetes as a Cloud Platform 20.1.5 Grafana Setup in Minikube 20.2 Amazon Elastic Kubernetes Service 20.2.1 Creating Clusters with “eksctl” 20.2.2 Deleting Data Clusters 20.3 Microsoft Azure Kubernetes Service 20.3.1 Creating Clusters 20.3.2 Installing an Application 20.3.3 Starting the Application 20.3.4 First Test 20.3.5 Tidying Up 20.4 Google Kubernetes Engine 20.4.1 Creating a Project and Cluster 20.4.2 The “gcloud” Command 20.4.3 The Diary Application in the Google Kubernetes Engine 20.4.4 Using Secure Sockets Layer Certificates from Let’s Encrypt A Podman as a Docker Alternative A.1 Docker versus Podman from a Technical Perspective A.2 Installing Podman A.3 Container Registries A.4 Hello World! A.5 Storage Location for Containers and Images A.6 Compatibility of the “podman” Command A.7 No “ping” A.8 Volumes A.9 “podman secret” A.10 Access to Container File Systems (“podman mount”/“umount”) A.11 Managing Pods (“podman pod”) A.12 Creating Images (“podman build”, “buildah”) A.13 Running “docker-compose” in Podman A.14 “podman-compose” Instead of “docker-compose” B The Authors Index Service Pages Legal Notes
Donate to keep this site alive
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.