Video by freeCodeCamp.org · taught by Sanjeev Thiyagarajan · streamed from YouTube. All rights remain with the creator.
Lesson 3: Docker for Node.js and Express: Development to Production
About this lesson
This project-based course by Sanjeev Thiyagarajan teaches the fundamentals of Docker by containerising a real Node.js and Express application and taking it all the way to production. It is arranged in three parts. The first part starts with a small Express app and builds a custom image with a Dockerfile, explaining image layers and caching, publishing ports, and excluding files with a .dockerignore file. It then shows how to sync source code into a running container with bind mounts, a trick using anonymous volumes to protect installed dependencies, read-only mounts, environment variables and loading them from a file, before introducing Docker Compose and separate configurations for development and production. The second part adds more containers. A MongoDB database is connected, you see how containers talk to each other by name and how to deal with the order in which they start, and a full application to create, read, update and delete data is built, followed by sign-up, log-in and sessions stored in Redis. Nginx is added to balance traffic across several Node containers. The third part moves to production on an Ubuntu server: installing Docker, setting up Git and environment variables, deploying, and pushing changes first the hard way and then with an improved workflow through Docker Hub. The course automates updates with Watchtower, explains why an orchestrator is needed, and finishes with Docker Swarm and rolling out changes to a stack. Afterwards, read Chapter 3 of the course book.