Containerize a Web App with Docker
Package a Node.js app into a Docker container and publish it to Docker Hub.
Introduction
30 Second Summary
You have probably heard the classic developer excuse: "it works on my machine." The reason software breaks when it moves between computers is that each machine has different settings, versions, and dependencies installed.
In this project, you will package a web application into a Docker container so it runs the exact same way on any machine. You will build the container, run it locally, and publish it to Docker Hub for anyone in the world to use.
What You'll Build
A containerized Node.js web application published to Docker Hub, proving you can package, ship, and run apps the way real DevOps teams do in production.
By the end of this project, you'll have:
- A custom Dockerfile that builds your app into a portable container image.
- A running Docker container serving your web app on localhost.
- A public Docker Hub repository with your published image that anyone can pull and run.
- Secret Mission: Add a health check endpoint and configure Docker's HEALTHCHECK instruction to monitor your container automatically.
Are there any prerequisites?
You should have basic familiarity with using Terminal on macOS. No prior Docker or containerization experience is needed.
Install Docker Desktop and Create a Docker Hub Account
To run containers on your Mac, you need Docker Desktop. It provides the Docker engine, CLI tools, and a graphical interface for managing your containers.
You also need a Docker Hub account to publish your container images online. In this step, you will install Docker Desktop, create your Docker Hub account, and connect the two from your Terminal.
In this step, get ready to:
- Install Docker Desktop and verify the Docker CLI works.
- Create a free Docker Hub account.
- Log in to Docker Hub from Terminal.
Download and install Docker Desktop
Docker Desktop is a free application for macOS that bundles everything you need to build and run containers locally.
- Open your browser and go to docker.com/products/docker-desktop.
- Click Download for Mac.
- Choose the chip type that matches your Mac. Select Apple Silicon if you have an M1, M2, M3, or M4 Mac. Select Intel if you have an older Intel-based Mac.
- Once the .dmg file downloads, double-click it to open the installer.
- Drag the Docker icon into your Applications folder.
Not sure which chip you have?
Click the Apple menu in the top-left corner of your screen, then click About This Mac. If the Chip field says Apple M1, M2, M3, or M4, choose Apple Silicon. If it says Intel, choose Intel.
Launch Docker Desktop and verify the installation
- Press Cmd+Space to open Spotlight search.
- Type Docker and press Enter to open Docker Desktop.
- Accept the license agreement when prompted.
- Wait for Docker Desktop to finish starting up. You will see the Docker whale icon appear in your menu bar at the top of the screen.
Docker Desktop runs in the background and powers the docker command in Terminal. Let's confirm the CLI is working.
- Press Cmd+Space to open Spotlight search.
- Type Terminal and press Enter to open it.
- Check your Docker installation by running this command:
docker --version
✔️ I see a version number
Docker is installed and ready to go. You should see something like Docker version 28.x.x. The exact version number does not matter as long as you see output.
ⓧ Command not found
This means Docker Desktop is not running or did not finish installing.
- Make sure Docker Desktop is open. Look for the whale icon in your menu bar at the top of the screen.
- If Docker Desktop is open but still starting, wait for the whale icon to stop animating, then try the command again.
- If you do not see Docker Desktop in your Applications folder, re-download and install it from docker.com.
Why Docker Desktop?
Docker Desktop provides the Docker engine (which actually runs containers), the CLI (which you use in Terminal), and a visual dashboard. It is free for personal use, education, and small businesses.
Create a Docker Hub account
Docker Hub is a public registry where you store and share container images. Think of it like GitHub, but for containers instead of code.
- Open your browser and go to hub.docker.com.
- Click Sign Up.
- Enter your email address, choose a Docker ID (this is your username, 4-30 characters, lowercase letters and numbers only), and set a password (minimum 9 characters).
- Check your email inbox for a verification code from Docker.
- Enter the verification code on the Docker sign-up page to confirm your account.
Remember your Docker ID
Your Docker ID is the username you will use to push images later. Write it down or save it somewhere accessible. You will need it in Step 5.
Not receiving the verification email?
Check your spam or junk folder. The email comes from Docker and can take a minute to arrive. If it does not show up, click the resend link on the Docker sign-up page.
help me sign up for Docker Hub
Log in to Docker Hub from Terminal
Your Terminal needs to authenticate with Docker Hub so you can push images later. The docker login command connects your local Docker installation to your Docker Hub account.
- In Terminal, log in to Docker Hub by running this command:
docker login
What happens when you run this?
Docker uses a web-based device code flow. It displays a one-time code in your Terminal and opens (or asks you to open) a URL in your browser. Paste the code in the browser to authorize your Terminal session.
- Copy the one-time code displayed in Terminal.
- Open the URL shown in Terminal (or let it open automatically in your browser).
- Paste the code in your browser and click Confirm.
- Switch back to Terminal. You should see Login Succeeded.
Login not working?
Make sure Docker Desktop is running (whale icon visible in your menu bar). The docker login command requires the Docker engine to be active.
If the browser-based flow does not work, try running docker login -u YOUR_DOCKER_ID and enter your password when prompted.
help me troubleshoot docker login
Your Docker environment is ready. Next up, you will create a simple web app that you will containerize in the following steps.
Create a Simple Web App
You've got Docker installed and your Docker Hub account ready to go. Now it's time to build the application you'll containerize.
Before Docker can package anything, it needs an actual app to work with. You'll create a simple web server using Node.js and Express that displays a page in your browser.
In this step, get ready to:
- Create a project folder with an Express web app.
- Set up the app's package.json with dependencies.
- Test that the app runs locally in your browser.
Create your project folder and write the Express app
Your web app needs Node.js to run. Let's confirm it's installed on your machine before creating any files.
- Check your Node.js installation by running this command in Terminal:
node --version
✔️ I see a version number
Node.js is ready. Move on to the next instruction below.
ⓧ Command not found
You need to install Node.js. Follow these steps:
- Visit nodejs.org/en/download in your browser.
- Click the macOS installer option to download the .pkg file.
- Open the downloaded .pkg file and follow the prompts to install.
- Once installed, close and reopen Terminal, then run node --version again to confirm.
- Move to your Desktop by running this command:
cd ~/Desktop
- Create your project folder and move into it by running these commands:
mkdir my-web-app
cd my-web-app
- Confirm the folder was created by running:
ls ~/Desktop
You should see my-web-app listed in the output.
Now you'll create the main app file. This is the Express server that will eventually run inside your Docker container.
- Create a new file called index.js inside your my-web-app folder by running:
touch index.js
- Open index.js in your text editor and paste in the following code:
const express = require('express');
const app = express();
const port = 3000;
// Define what happens when someone visits the homepage
app.get('/', (req, res) => {
res.send('<h1>Hello Docker!</h1><p>This app is running inside a Docker container.</p>');
});
// Start the server and listen for requests
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`);
});
What does this code do?
- const express = require('express') imports the Express framework, which makes it easy to create a web server.
- app.get('/', ...) defines a route that responds when someone visits the homepage. It sends back an HTML page.
- app.listen(port, ...) starts the server on port 3000 so your browser can connect to it.
- Save index.js.
File not saving?
Make sure you're saving the file inside the my-web-app folder on your Desktop. If you opened your editor to a different location, use File > Save As to navigate to the correct folder.
help me find where my file saved
✔️ Awesome, I've got everything!
Great. Make sure you've saved the file before moving on.
ⓧ I'd like to double check the full code
const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('<h1>Hello Docker!</h1><p>This app is running inside a Docker container.</p>');
});
app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`);
});
Create the package.json file
Every Node.js project needs a package.json file. It tells Node.js the project's name, version, and which packages (like Express) it depends on.
- Create a new file called package.json inside your my-web-app folder by running:
touch package.json
- Open package.json in your text editor and paste in the following code:
{
"name": "my-web-app",
"version": "1.0.0",
"description": "A simple web app containerized with Docker",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.21.0"
}
}
What does this file do?
- "name" and "version" identify your project.
- "main" tells Node.js which file to run when the app starts.
- "scripts" defines shortcuts. Running npm start is the same as running node index.js.
- "dependencies" lists the packages your app needs. Express ^4.21.0 means any compatible version from 4.21.0 onward.
- Save package.json.
- Confirm both files exist in your project folder by running:
ls
You should see index.js and package.json listed in the output.
Only seeing one file?
Make sure both files were saved inside the my-web-app folder. If a file is missing, create it again with touch and re-paste the code. Also check that your Terminal is in the right folder by running pwd.
help me find my missing file
✔️ Awesome, I've got everything!
Great. Both files are ready for the next part.
ⓧ I'd like to double check the full code
{
"name": "my-web-app",
"version": "1.0.0",
"description": "A simple web app containerized with Docker",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.21.0"
}
}
Test the app locally
Before containerizing anything, you want to confirm the app works on its own. This way you'll know any issues later are Docker-related, not app-related.
- Install the project's dependencies by running:
npm install
- Confirm the installation worked by running:
ls
You should now see a node_modules folder in the output. This folder contains Express and all of its sub-dependencies.
Seeing errors from npm install?
Check that your package.json is valid JSON. A missing comma, extra comma, or mismatched bracket will cause npm to fail. Open the file and compare it to the code above.
Also confirm you're running the command inside the my-web-app folder. Run pwd to check your current location.
help me fix my npm install error
- Start your app by running:
node index.js
You should see this message in your Terminal:
App listening at http://localhost:3000
- Open your browser and visit http://localhost:3000.
You should see a page with the heading "Hello Docker!" and a paragraph that says "This app is running inside a Docker container."
Why does it say Docker when it's not in a container yet?
The message is a preview of what the finished containerized app will show. Right now the app is running directly on your Mac. In the next steps, you'll package it into a Docker container where it will serve the same page.
- Go back to your Terminal and press Ctrl+C to stop the server.
Page not loading in your browser?
Make sure the Terminal still shows "App listening at http://localhost:3000" without any errors. If you see an error like Cannot find module 'express', it means npm install didn't run successfully. Stop the server with Ctrl+C, run npm install again, then try node index.js once more.
If you see EADDRINUSE, port 3000 is already in use by another process. Close any other servers or apps using that port and try again.
help me get my app running on localhost
Your app works locally. Next up, you'll write a Dockerfile to package this app into a portable container image that can run anywhere.
Write Your Dockerfile
In the last step, you built a working Express app that serves a page on port 3000. Right now, that app only runs on your Mac because it depends on your local Node.js installation.
A Dockerfile is a recipe that tells Docker exactly how to package your app into a container image. Once you have that image, anyone with Docker can run your app regardless of what's installed on their machine.
In this step, get ready to:
- Create a Dockerfile that packages your app into a container image.
- Create a .dockerignore file to keep unnecessary files out of the image.
- Build your first Docker image.
Create your Dockerfile
A Dockerfile contains a series of instructions that Docker reads top to bottom. Each instruction adds a new layer to your image, starting from a base image and ending with the command that runs your app.
- In your text editor, create a new file called Dockerfile inside your my-web-app folder.
- Make sure the file is named exactly Dockerfile with a capital D and no file extension.
- Paste the following code into the file:
FROM node:20-alpine
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]
What does each instruction do?
- FROM node:20-alpine starts from the official Node.js 20 image built on Alpine Linux, a lightweight Linux distribution that keeps your image small.
- WORKDIR /app creates a /app directory inside the container and sets it as the working directory for all following instructions.
- COPY package.json ./ copies only your package.json first, so Docker can cache the dependency install step separately from your code changes.
- RUN npm install installs your dependencies inside the image.
- COPY . . copies the rest of your app files into the container.
- EXPOSE 3000 documents that the container listens on port 3000.
- CMD ["node", "index.js"] sets the command that runs when the container starts.
Why copy package.json separately?
Docker caches each layer. If you copy all files first and then run npm install, Docker has to reinstall every dependency whenever any file changes.
By copying package.json alone and installing first, Docker reuses the cached dependencies layer unless package.json itself changes. This makes rebuilds much faster.
- Save Dockerfile.
File not recognized as a Dockerfile?
- Make sure the file is named exactly Dockerfile with a capital D. No extension like .txt or .dockerfile.
- The file must be in the root of your my-web-app folder, not inside a subfolder.
Help me troubleshoot my Dockerfile naming issue.
Create a .dockerignore file
Your COPY . . instruction copies everything in your project folder into the image. That includes node_modules, which you don't want because the image already runs its own npm install.
- Create a new file called .dockerignore in your my-web-app folder.
- Paste the following content into the file:
node_modules
npm-debug.log
.git
.gitignore
What does this file do?
A .dockerignore works like a .gitignore but for Docker builds. Any file or folder listed here is excluded from the COPY instructions in your Dockerfile.
This keeps your image smaller and prevents your local node_modules from overwriting the ones installed inside the container.
- Save .dockerignore.
- Confirm both new files exist by running:
ls -a
You should see Dockerfile and .dockerignore listed alongside your existing files.
Don't see .dockerignore in the list?
- Files starting with a dot are hidden by default. The -a flag in ls -a reveals them.
- If you ran just ls without the -a flag, try again with ls -a.
- Check that your editor didn't save the file as dockerignore without the leading dot.
Help me find my .dockerignore file.
✔️ Awesome, I've got everything!
Great. Double check you've saved both files before moving on to the build.
ⓧ I'd like to double check the full code
Here's the full Dockerfile:
FROM node:20-alpine
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]
And the full .dockerignore:
node_modules
npm-debug.log
.git
.gitignore
Build your Docker image
Your Dockerfile is a set of instructions. Building turns those instructions into an actual image that Docker can run as a container.
- Build your Docker image by running this command:
docker build -t my-web-app .
What does this command do?
- docker build reads your Dockerfile and executes each instruction to create an image.
- -t my-web-app tags (names) the image so you can reference it easily later.
- . tells Docker to use the current directory as the build context (where to find the Dockerfile and files to copy).
You should see Docker processing each step of your Dockerfile in the terminal output. It downloads the node:20-alpine base image, installs your dependencies, and finishes with a success message.
- Verify your image was created by running:
docker images
You should see my-web-app listed in the output table with a latest tag and a size of roughly 130-140 MB.
Build failed with an error?
- If you see no such file or directory, make sure you are running the command from inside the my-web-app folder where your Dockerfile lives.
- If you see a syntax error, double check your Dockerfile matches the code above exactly. Each instruction must be on its own line.
- If Docker cannot connect, make sure Docker Desktop is running. Check for the whale icon in your menu bar.
Help me debug my Docker build error.
Your app is now packaged into a Docker image. Next up, you'll run it as a live container and see your app served entirely from Docker.
Run Your Container and Test It
You have a Docker image built and ready to go. The image is like a blueprint. Now it is time to create a running instance of that blueprint.
In this step, you will start a container from your image, verify your app is serving traffic, explore what is happening inside the container, and then clean it up.
In this step, get ready to:
- Start your container and visit your app in the browser.
- Explore container management commands to inspect and interact with your running container.
- Stop and remove the container to clean up.
Start your container
A Docker image on its own does not do anything. You need to run it as a container to bring your app to life.
- Start a container from your image by running this command:
docker run -d -p 3000:3000 --name my-app my-web-app
What does this command do?
- docker run creates and starts a new container from the my-web-app image.
- -d runs the container in detached mode, so it runs in the background and gives you your Terminal back.
- -p 3000:3000 maps port 3000 on your Mac to port 3000 inside the container. This is called port mapping.
- --name my-app gives your container a friendly name so you can refer to it easily.
- Open your browser and visit http://localhost:3000.
- You should see a page with Hello Docker! as the heading and This app is running inside a Docker container. below it.
Your app is no longer running directly on your Mac. It is running inside an isolated container.
Why does port mapping matter?
Containers are isolated from your host machine by default. Without the -p flag, your browser cannot reach the app inside the container.
Port mapping creates a tunnel between your Mac and the container. The format is host_port:container_port. You could map to a different host port (like -p 8080:3000) if port 3000 was already in use on your Mac.
Don't see your app in the browser?
- Make sure you stopped the local Node.js server from the previous step. If node index.js is still running, it occupies port 3000 and the container cannot bind to it.
- Check that Docker Desktop is still running. Look for the whale icon in your menu bar.
- Confirm the container started by running docker ps. If my-app is not listed, re-run the docker run command.
Why can't I access my container at localhost:3000?
Explore container management commands
Your container is running in the background. Docker gives you several commands to inspect what is happening inside without stopping it.
- List all running containers by running this command:
docker ps
You should see a table with one row showing my-app in the NAMES column and Up in the STATUS column.
What does docker ps show?
The output shows your container's ID, the image it was built from, how long it has been running, its port mappings, and its name. Think of it like a task manager for containers.
- View the logs from your running container by running this command:
docker logs my-app
You should see App listening at http://localhost:3000 in the output. This is the same console.log message from your index.js file.
- Open an interactive shell inside the running container by running this command:
docker exec -it my-app sh
What does docker exec do?
- docker exec runs a command inside an already-running container.
- -it makes the session interactive so you can type commands.
- sh opens a shell. Alpine Linux uses sh instead of bash.
Your Terminal prompt changes to something like /app $. You are now inside the container.
- List the files inside the container by running:
ls
You should see Dockerfile, index.js, node_modules, and package.json. These are the files Docker copied into the container when it built the image.
- Exit the container shell by typing:
exit
You are back on your Mac's Terminal. The container is still running in the background.
Shell not responding?
- If your Terminal seems stuck after running docker exec, press Ctrl+C to interrupt, then try the command again.
- If you accidentally closed Terminal, open a new Terminal window. The container is still running in the background.
Help me troubleshoot docker exec not working on my container.
Stop and remove the container
Running containers use system resources. When you are done testing, you should stop and remove them to keep your machine clean.
- Stop your running container by running this command:
docker stop my-app
This sends a graceful shutdown signal to the container. You should see my-app printed as confirmation.
- Remove the stopped container by running this command:
docker rm my-app
You should see my-app printed again, confirming the container has been deleted.
- Verify the container is gone by running:
docker ps -a
The -a flag shows all containers, including stopped ones. Your my-app container should no longer appear in the list.
Why stop AND remove?
Stopping a container shuts it down but keeps it on disk. You could restart it later with docker start my-app.
Removing deletes the container permanently. Your image still exists, so you can always create a fresh container from it.
Error: No such container?
- If you see No such container: my-app when running docker stop, the container may have already stopped or was never started. Run docker ps -a to check.
- If you see the error on docker rm, the container may have already been removed. This is safe to ignore.
Help me figure out why docker stop or docker rm is giving me an error.
You have successfully run your app inside a container, explored it, and cleaned up. Next up, you will push your image to Docker Hub so anyone in the world can pull and run it.
Push Your Image to Docker Hub
In the previous step, you ran your app inside a Docker container and explored how to manage it.
Right now, your Docker image only exists on your Mac. If you wanted to run it on a server, share it with a teammate, or deploy it to the cloud, you would need to send them the entire project and have them build it themselves. That defeats the whole point of containers.
Docker Hub solves this. It is a public registry where you can push your images so anyone can pull and run them instantly. In this step, you will tag your image, push it to Docker Hub, and verify the full publish-and-pull workflow.
In this step, get ready to:
- Tag your image with your Docker Hub username and a version number.
- Push the tagged image to Docker Hub.
- Verify the full workflow by pulling the image back from Docker Hub.
Tag your image for Docker Hub
Docker Hub needs to know who owns an image. Before you can push, you must tag your image with your Docker Hub username and a version number. The tag format is username/repository:tag.
- Tag your local image for Docker Hub by running this command:
docker tag my-web-app [[DOCKERUSER="your-docker-hub-username"]]/my-web-app:v1.0
What does this command do?
This does not create a new image. It adds an additional name (tag) to your existing my-web-app image.
- Your Docker Hub username acts as the namespace, telling Docker Hub which account owns the image.
- v1.0 is the version tag. This lets you push multiple versions of the same image over time.
- Verify the tag was applied by running:
docker images
You should see two entries for your image. One tagged as my-web-app:latest and another tagged as your-username/my-web-app:v1.0. Both point to the same image ID.
Don't see the tagged image?
- Make sure you replaced the username placeholder with your actual Docker Hub username. It must be lowercase.
- Check that your original my-web-app image still exists by looking through the docker images output.
Help me troubleshoot my docker tag command
Push the image to Docker Hub
Now that your image has the right tag, you can push it to Docker Hub. This uploads all the layers of your image to the registry so others can pull and run it.
- Push your tagged image to Docker Hub by running this command:
docker push [[DOCKERUSER="your-docker-hub-username"]]/my-web-app:v1.0
What does this command do?
Docker breaks your image into layers. The push command uploads each layer to Docker Hub. You will see progress bars for each layer as they upload.
Since your image is based on node:20-alpine, Docker Hub already has those base layers. Only the layers unique to your app (your code and installed packages) actually get uploaded.
Wait for the push to complete. You should see each layer finish with a hash and size, followed by a final digest line confirming the push succeeded.
Seeing "denied: requested access to the resource is denied"?
- Make sure the username in your tag matches your Docker Hub username exactly. Docker Hub usernames are case-sensitive.
- Confirm you are logged in by running docker login again. Complete the device code flow in your browser.
- If you recently created your Docker Hub account, make sure you verified your email address.
Help me fix my docker push access denied error
Verify the full workflow
Pushing is only half the story. To prove your image is truly portable, you will delete your local copy and pull it back from Docker Hub. This simulates what happens when someone else (or a server) runs your image for the first time.
- Open your browser and go to hub.docker.com.
- Sign in and click on your profile avatar in the top right corner.
- Click My Profile.
- You should see a my-web-app repository listed with the v1.0 tag.
Now test the pull workflow. Back in Terminal, remove your local images and pull them fresh from Docker Hub.
- Remove both local image tags by running these commands:
docker rmi my-web-app
docker rmi [[DOCKERUSER="your-docker-hub-username"]]/my-web-app:v1.0
What does rmi do?
The docker rmi command removes image tags from your machine. Since both tags pointed to the same image, removing both frees up the disk space. This simulates starting from a clean machine.
- Pull your image back from Docker Hub by running this command:
docker pull [[DOCKERUSER="your-docker-hub-username"]]/my-web-app:v1.0
You should see Docker downloading each layer, finishing with a "Status: Downloaded newer image" message. This confirms your image is live on Docker Hub and anyone can pull it.
- Confirm the pulled image exists locally by running:
docker images
You should see your your-username/my-web-app:v1.0 image listed again, freshly pulled from the registry.
Seeing "image is referenced in multiple repositories"?
- This means you need to remove both tags before the image layers are freed. Make sure you run both docker rmi commands shown above.
- If a container is still using the image, remove the container first with docker rm my-app.
Help me remove my Docker images
Your image is now live on Docker Hub. Anyone in the world can run your app with a single docker pull command. That is the power of containerization. Next up, the Secret Mission challenges you to add automated health monitoring to your container.
Secret mission
Add a Health Check to Your Container
In production, containers can crash silently. Docker's HEALTHCHECK instruction lets you monitor whether your app is actually responding, not just running. Add a health endpoint and configure automatic monitoring so Docker restarts unhealthy containers.
Clean Up Your Resources
Clean Up Your Resources
This project runs entirely locally using Docker Desktop and a free Docker Hub account, so there are no ongoing costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
Resources you used:
- Docker Desktop (installed on your Mac).
- Docker Hub account (with your published image).
- Local Docker images and containers.
- Project folder (my-web-app on your Desktop).
- Node.js and npm (installed locally).
Keep everything running
No action needed. Choose this if you're still actively building or plan to continue experimenting with Docker right away.
- Your Docker Desktop stays running in the background.
- Your local images remain available for instant container creation.
- Your Docker Hub image stays public for anyone to pull.
Pause - I'll come back to this later
Shut down running containers and quit Docker Desktop to free up memory. Your project files and Docker Hub image stay intact for when you return.
- Stop any running containers by running:
docker stop $(docker ps -q)
- Quit Docker Desktop by clicking the Docker icon in your menu bar and selecting Quit Docker Desktop.
- Your project folder, local images, and Docker Hub repository all remain untouched.
- When you return, just relaunch Docker Desktop and your images will be ready to use.
Delete - I don't want to use this again
Remove all project resources and start fresh. This cleans up Docker images, containers, your project folder, and optionally your Docker Hub repository.
- Remove all stopped containers and unused images by running:
docker system prune -a
- Delete your project folder from your Desktop.
- To delete your Docker Hub repository, visit hub.docker.com, navigate to your repository, click Settings, then click Delete Repository.
- To uninstall Docker Desktop, open Finder, go to Applications, and drag Docker to the Trash.
Nice Work!
Nice Work!
You just containerized your first application like a real DevOps engineer. You now have a portable Docker image that anyone in the world can pull and run in seconds.
Here's what you learned:
- Written a Dockerfile to package a Node.js web app into a portable container image.
- Built and ran containers locally with port mapping, and managed the full container lifecycle with commands like docker build, docker run, docker stop, and docker rm.
- Published your image to Docker Hub so anyone can pull and run your containerized app.
- Added a Docker HEALTHCHECK to monitor your container automatically (Secret Mission).
Ready to quiz yourself?