Skip to content

Harsheetsharma/docker-networking

Repository files navigation

🚀 Express + TypeScript + Docker Networking Demo

This is a simple Express application built using TypeScript.
Here, we learn how Docker networking works — specifically, how one container talks to another using Docker's built-in networking.


🧠 What You'll Learn

  • 📦 Running multiple containers
  • 🔗 Connecting containers using Docker networks
  • 🗃️ Connecting a backend to a MongoDB container

🛠️ Setup Instructions

Follow these steps carefully:


🔧 Step 1: Create a Docker Network

docker network create <your-network-name>

🔧 Step 2: Run MongoDB Container in the Network

docker run -d -p 27017:27017 --name mongo --network <your-network-name> mongo

🔧 Step 3: Update Connection String

const uri = "mongodb://mongo:27017/<your-db-name>";

🔧 Step 4: Run Your Backend App in the Same Network

docker build -t my-backend .
docker run -p 3000:3000 --name my-app --network <your-network-name> my-backend

Result = mongoDB connected

Docker-compose.yaml is added - will create two container

  1. The mongogb will start.
  2. The backend process will start.
  3. Volume will be created to store the data.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published