Docker for Web Developers
Docker for Web Developers
A concise, practical, and easy-to-follow guide showing how Docker can quickly create web development environments on Windows, macOS, or Linux.
About the Book
How long does it take you to install web development dependencies?
A typical WordPress installation requires Apache, PHP, MySQL, and the application itself. Can those be installed on your OS? Are they identical across all platforms? With a single command, Docker can have them all running on Windows, macOS, or Linux in minutes. That environment can be transferred to another developer, device, or OS - it will work identically.
Docker benefits include…
- dependencies are isolated: other than disk space, your PC is not changed. It's possible to run multiple versions of the same software at the same time, e.g. MySQL v5 and v8.
- your web app becomes portable: it will work on any device regardless of the OS.
- dependencies are lightweight: they can be started, stopped, removed, or reinstalled at any time.
- older dependencies are supported: your app can continue to use the same dependencies forever.
- risk-free development: your app is isolated - you can experiment without affecting your PC stability.
- use the same tools and workflows: use whatever editor you like on Windows, macOS, or Linux.
- deployments are more robust: your app can be launched on live servers and scaled according to demand.
Despite this, Docker is often shunned by web developers.
Docker is the most useful web development tool you're not using
It's considered too technical, unnecessary, or something for DevOps experts. Terminology and resources can be impenetrable and tutorials never explain how to use Docker during development. Until now…
"Docker for Web Developers" offers a concise and practical course with example projects that can be adapted for any software stack. You'll be using Docker in minutes and can progress at your own pace.
Reader Testimonials
Ben Frain
you’re missing a trick if you haven’t looked at Docker yet
I knew the sum total of nothing about Docker a month ago. I certainly didn't appreciate what it could do for the average web developer.
Lukas White
"Docker for Web Developers" converted me!
Docker seemed overly complex but you demystified it very well – thanks!
Table of Contents
- About this book
- 0.1 Preface
- 0.2 Prerequisites
- 0.3 Course website
- 0.4 Book and/or videos?
- 0.5 Example code
- 0.6 Chat room
- 0.7 Code conventions
- 0.8 Further tips
- 0.9 About me
- 0.10 Copyright and distribution
---
1 Introduction- 1.1 "It works on my machine, buddy"
- 1.2 Virtual machining
- 1.3 Docker delivers
- 1.4 Nah, I'm still not convinced
- 1.5 Isn't {insert-technology-here} where it's at?
- 1.6 Key points
---
2 What is Docker?- 2.1 Containers
- 2.2 Images
- 2.3 Volumes
- 2.4 Networks
- 2.5 Docker Compose
- 2.6 Orchestration
- 2.7 Docker client-server application
- 2.8 Docker development strategies
- 2.9 Simpler development and production
- 2.10 When not to use Docker
- 2.11 Docker alternatives
- 2.12 Key points
---
3 How to install Docker- 3.1 Install Docker on Linux
- 3.2 Install Docker on macOS
- 3.3 Install Docker on Windows
- 3.4 Test your Docker installation
- 3.5 Key points
---
4 Launch a MySQL database with Docker- 4.1 Locate a suitable MySQL image on Docker Hub
- 4.2 Launch a MySQL container
- 4.3 Connect to the database using a MySQL client
- 4.4 Connect to a container shell
- 4.5 View, stop, and restart containers
- 4.6 Define a Docker network
- 4.7 Cleaning up
- 4.8 Launch multiple containers with Docker Compose
- 4.9 Key points
---
5 WordPress development with Docker- 5.1 WordPress requirements
- 5.2 Docker configuration plan
- 5.3 Docker Compose configuration
- 5.4 Launch your WordPress environment
- 5.5 Install WordPress
- 5.6 Local WordPress Development
- 5.7 Key points
---
6 Application development with Docker- 6.1 Container-based application development
- 6.2 What is Node.js?
- 6.3 Hello World application overview
- 6.4 Docker configuration plan
- 6.5 Dockerfiles
- 6.6 Build an image
- 6.7 Launch a production container from your image
- 6.8 Launch a development environment with Docker Compose
- 6.9 Live code editing
- 6.10 Remote container debugging
- 6.11 Create an image from a container
- 6.12 Key points
---
7 Push your Docker image to a Repository- 7.1 Why push an image to Docker Hub?
- 7.2 Docker Hub alternatives
- 7.3 Image names and tags
- 7.4 Create a Docker Hub repository
- 7.5 Log in locally
- 7.6 Build an application image
- 7.7 Tag an image
- 7.8 Push to Docker Hub
- 7.9 Distribute your image
- 7.10 Key points
---
8 Docker orchestration on production servers- 8.1 Dependency planning
- 8.2 Application scaling
- 8.3 Orchestration overview
- 8.4 Docker Swarm
- 8.5 Kubernetes
- 8.6 Key points
---
9 Your Docker journey- 9.1 Docker's future
- 9.2 Further Docker help
---
10 Appendix A: Docker command-line reference- 10.1 Log into Docker Hub
- 10.2 Search Docker Hub
- 10.3 Pull a Docker Hub image
- 10.4 List Docker images
- 10.5 Build an image from a Dockerfile
- 10.6 Tag an image
- 10.7 Push tagged images to Docker Hub
- 10.8 Launch a container from an image
- 10.9 List containers
- 10.10 Run a command in a container
- 10.11 Attach to a container shell
- 10.12 Restart a container
- 10.13 Pause a container
- 10.14 Unpause (resume) a container
- 10.15 View container metrics
- 10.16 Increase container resources
- 10.17 Stop a container
- 10.18 Remove stopped containers
- 10.19 View Docker volumes
- 10.20 Delete a volume
- 10.21 Bind mount a host directory
- 10.22 Define a Docker network
- 10.23 View networks
- 10.24 Delete a network
- 10.25 View system disk usage
- 10.26 Full clean start
---
11 Appendix B: Dockerfile reference- 11.1
#
comment - 11.2
ARG
arguments - 11.3
ENV
environment variables - 11.4
FROM <image>
starting image - 11.5
WORKDIR
working directory - 11.6
COPY
files from the host to image - 11.7
ADD
files - 11.8 Mount a
VOLUME
- 11.9 Set a
USER
- 11.10
RUN
a command - 11.11
EXPOSE
a port - 11.12
CMD
execute container - 11.13
ENTRYPOINT
execute container - 11.14
.dockerignore
file patterns
- 11.1
---
12 Appendix C: Docker Compose reference- 12.1 Docker Compose CLI
- 12.2
docker-compose.yml
outline - 12.3 Starting
image
- 12.4
build
an image from aDockerfile
- 12.5 Set the
container_name
- 12.6 Container
depends_on
another - 12.7 Set
environment
variables - 12.8 Set environment variables from a
env_file
- 12.9 Attach to Docker
networks
- 12.10 Attach persistent Docker
volumes
- 12.11 Set a custom
dns
server - 12.12
expose
ports - 12.13 Define
external_links
to other containers - 12.14 Override the default
command
- 12.15 Override the default
entrypoint
- 12.16 Specify a
restart
policy - 12.17 Run a
healthcheck
- 12.18 Define a logging service
---
13 Appendix D: quiz project- 13.1 Project overview
- 13.2 Launch in development mode
- 13.3 Launch in production mode
- 13.4 Clean up
- 13.5 Project file structure
- 13.6
nodejs
Docker image - 13.7
nginx
Docker image - 13.8
mongodb
Docker image - 13.9 Node.js build process
- 13.10 Node.js Express.js application
- 13.11 Client-side files
- 13.12 Key points
Authors have earned$9,883,643writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
I am a Software Engineer and I am in Charge
Alexis Monville and Michael DoyleI am a Software Engineer and I am in Charge is a real-world, practical book that helps you increase your impact and satisfaction at work no matter who you work with.
In the book, we will follow Sandrine, a fictional character who learns to think in a new way enabling her to take a different course of action.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
Invest In Digital Health - The Medical Futurist's Guide
Dr. Bertalan MeskoArtificial Intelligence and Digital Health are booming. In this book, we explain why now it's a good time to invest in Digital Health and give recommendations on where to invest by looking at the top 24 technological trends we find the most promising.
The Hundred-Page Machine Learning Book
Andriy BurkovEverything you really need to know in Machine Learning in a hundred pages.
Mastering STM32
Carmine NovielloWith more than 600 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the first guide around that introduces the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
The Future of Digital Health
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer... - #4
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #5
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #6
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #7
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #8
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #9
Programming with Ease
3 Books
Alle drei Bände der Serie Programming with Ease in einem Paket. Darin findest du alles, was ich dir zu den wichtigsten Phasen der Softwareentwicklung im Hinblick auf Clean Code Development für langfristig hohe Produktivität sagen kann.Im Band Slicing findest du die Anforderungsanalyse im Rahmen eines iterativ-inkrementellen Vorgehensmodells aus... - #10
Vagrant Ansible
2 Books
Unveil the power of Ansible and Vagrant with this bundle at a special price. You'll have everything you need to get started with Vagrant - learn the basics and how to create your virtual development environments, using Ansible as provisioner! About Vagrant Cookbook Vagrant Cookbook is a complete guide to get started with Vagrant and create your...