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
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
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) and EPUB (for phones, tablets and 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