Author(s): Rob Isenberg
Edition: 1 edition (February 24, 2019)
Publisher: Pragmatic Bookshelf
Year: 2019
Language: English
Pages: 240
Acknowledgements......Page 12
Introduction......Page 14
What Is Docker?......Page 15
Why Use Docker?......Page 16
Who Should Read This Book?......Page 18
What’s in This Book?......Page 19
How to Read This Book......Page 20
Which Operating Systems Are Supported?......Page 21
Online Resources......Page 22
Part I. Development......Page 23
1. A Brave New World......Page 24
Installing Docker......Page 25
Verifying Your Install......Page 27
Before We Begin......Page 28
Running a Ruby Script Without Ruby Installed......Page 30
Generating a New Rails App Without Ruby Installed......Page 34
Quick Recap......Page 41
2. Running a Rails App in a Container......Page 43
How Do We Run Our Rails App?......Page 44
Defining Our First Custom Image......Page 46
Building Our Image......Page 52
Running a Rails Server with Our Image......Page 55
Reaching the App: Publishing Ports......Page 58
Binding the Rails Server to IP Addresses......Page 61
Quick Recap......Page 63
3. Fine-Tuning Our Rails Image......Page 65
Naming and Versioning Our Image......Page 66
A Default Command......Page 69
Ignoring Unnecessary Files......Page 71
The Image Build Cache......Page 73
Caching Issue 1: Updating Packages......Page 75
Caching Issue 2: Unnecessary Gem Installs......Page 77
The Finishing Touch......Page 81
Quick Recap......Page 83
4. Describing Our App Declaratively with Docker Compose......Page 85
Getting Started with Compose......Page 86
Launching Our App......Page 88
Mounting a Local Volume......Page 92
Starting and Stopping Services......Page 94
Other Common Tasks......Page 97
Quick Recap......Page 101
5. Beyond the App: Adding Redis......Page 103
Starting a Redis Server......Page 105
Manually Connecting to the Redis Server......Page 108
How Containers Can Talk to Each Other......Page 110
Our Rails App Talking to Redis......Page 112
Starting the Entire App with Docker Compose......Page 116
Quick Recap......Page 118
6. Adding a Database: Postgres......Page 120
Starting a Postgres Server......Page 121
Connecting to Postgres from a Separate Container......Page 124
Connecting Our Rails App to Postgres......Page 126
Using the Database in Practice......Page 133
Decoupling Data from the Container......Page 135
Quick Recap......Page 140
7. Playing Nice with JavaScript......Page 142
The JavaScript Front-End Options......Page 143
Rails JavaScript Front End with Webpacker......Page 145
Compiling Assets with Webpacker......Page 148
A Hello World React App......Page 151
Quick Recap......Page 153
8. Testing in a Dockerized Environment......Page 154
Setting Up RSpec......Page 156
Our First Test......Page 158
Setting Up Rails System Tests......Page 161
Running Tests That Rely on JavaScript......Page 164
Debugging......Page 174
Quick Recap......Page 176
9. Advanced Gem Management......Page 178
The Downside to Our Existing Approach......Page 179
Using a Gem Cache Volume......Page 181
Quick Recap......Page 186
10. Some Minor Irritations......Page 187
Rails tmp/pids/server.pid Not Cleaned Up......Page 188
Compose Intermittently Aborts with Ctrl-C......Page 192
Quick Recap......Page 193
Closing Thoughts on Docker in Development......Page 194
Part II. Toward Production......Page 196
11. The Production Landscape......Page 197
The “Ops” in DevOps......Page 198
Container Orchestration......Page 201
A Tale of Two Orchestrators: Swarm and Kubernetes......Page 203
IaaS vs. CaaS......Page 205
Provisioning Your Infrastructure......Page 206
CaaS Platforms......Page 208
Serverless for Containers......Page 212
How to Decide What’s Right for Me?......Page 214
Quick Recap......Page 216
12. Preparing for Production......Page 219
Configuring a Production Environment......Page 220
A Production Image: Precompiling Assets......Page 223
Sharing Images......Page 225
Quick Recap......Page 233
13. A Production-Like Playground......Page 235
Creating Machines......Page 236
Introducing Docker Swarm......Page 242
Our First (Single Node) Swarm......Page 243
Describing Our App to Swarm......Page 244
Migrating the Database......Page 246
Deploying Our App on a Swarm......Page 250
Tasks and Swarm’s Scaling Model......Page 252
Scaling Up the Service......Page 254
Quick Recap......Page 259
14. Deploying to the Cloud......Page 262
Creating a DigitalOcean Cluster......Page 263
Deploying to Our DigitalOcean Swarm......Page 269
Visualizing Containers......Page 271
Scale Up the Web Service......Page 275
Deploying to AWS Instead of DigitalOcean......Page 278
Quick Recap......Page 281
15. Closing Thoughts and Next Steps......Page 283
What Should I Learn About Next?......Page 285
A1. Platform Differences......Page 295
File Ownership and Permissions......Page 296
A2. Finding Images to Use......Page 298
Using Docker Hub......Page 299
Using the Docker CLI......Page 301