This tutorial will teach you how to develop and deploy applications using Docker. You'll build a Docker Quiz Challenge - an interactive web application that tests your Docker knowledge with randomly selected questions and tracks scores in a MongoDB database.
A full-stack quiz application consisting of:
- Frontend: Interactive quiz interface with 5 randomly selected Docker MCQ questions from a pool of 10
- Backend: Node.js Express server handling quiz submissions and scoring
- Database: MongoDB storing player scores and leaderboard
- Admin UI: Mongo Express for viewing database records in real-time
By the end of this tutorial, you'll understand:
- How to run containers with
docker run - How to create custom Docker networks
- How to link containers together
- How to use Docker Compose to orchestrate multi-container applications
Let's explore the files in this repository:
developing-with-docker/
├── app/
│ ├── server.js # Node.js Express backend server
│ ├── package.json # Node.js dependencies and scripts
│ ├── index.html # Quiz application frontend
│ ├── questions.json # Docker MCQ questions
│ └── images/ # Application assets
├── Dockerfile # Instructions to build the app container image
├── docker-compose.yaml # Configuration for multi-container setup
└── README.md # This tutorial file
In this section, you'll learn Docker basics by manually running containers and connecting them together. We'll introduce Docker concepts and commands as we use them hands-on.
Here is a diagram of the architecture we'll set up:
Before we start, let's clarify two fundamental concepts:
- Docker Image: A read-only template containing application code, dependencies, and configuration. Think of it as a blueprint or snapshot.
- Docker Container: A running instance of an image. Containers are isolated, lightweight, and portable execution environments.
Analogy: An image is like a class in programming, while a container is an instance of that class.
What are Docker Networks?
Docker networks allow containers to communicate securely and in isolation. Containers on the same network can find each other by name, making it easy to connect services together.
Let's create a custom network for our MongoDB and Mongo Express containers:
docker network create mongo-networkThis creates an isolated network where our containers can find each other by name.
📝 Note: Creating a Docker network is optional. You can start containers in the default network by omitting the
--netflag, but using custom networks provides better isolation and easier container-to-container communication.
Understanding docker run
The docker run command creates and starts a container from an image. If the image doesn't exist locally, Docker automatically downloads it from Docker Hub (a public registry of container images).
Run a MongoDB container with the following configuration:
docker run -d \
-p 10000:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
-v $(pwd)/mongodb-data:/data/db \
--name mongodb \
--net mongo-network \
mongoWhat this command does:
-d: Runs container in detached mode (background)-p 10000:27017: Maps port 10000 from your host to container port 27017- Left side (10000): Port on your host machine - you'll connect to
localhost:10000 - Right side (27017): Port inside the container where MongoDB listens
- Left side (10000): Port on your host machine - you'll connect to
-v $(pwd)/mongodb-data:/data/db: Mounts a volume to persist database data. Without this, all data is lost when the container is deleted!- Left side:
$(pwd)/mongodb-data- Creates a folder in your current directory - Right side:
/data/db- Where MongoDB stores data inside the container
- Left side:
-e: Sets environment variables for MongoDB credentials--name mongodb: Names the container "mongodb"--net mongo-network: Connects to our custom networkmongo: The official MongoDB image from Docker Hub
Understanding Port Mapping (-p flag):
Containers run in isolation with their own network stack. When MongoDB runs inside a container, it listens on port 27017 inside that container's network. Without port mapping, your host machine (or applications running on your host) cannot reach MongoDB because the container's port 27017 is isolated and inaccessible from outside.
Port mapping creates a bridge between your host machine and the container, making the containerized service accessible.
Format: -p HOST_PORT:CONTAINER_PORT
- HOST_PORT (left side): The port on your computer/host machine
- CONTAINER_PORT (right side): The port inside the container where the application listens
By mapping to different host ports, you can run multiple MongoDB containers simultaneously:
- Development database:
docker run -p 10000:27017 --name mongodb-dev mongo - Testing database:
docker run -p 10001:27017 --name mongodb-test mongo - Production-like database:
docker run -p 10002:27017 --name mongodb-prod mongo
Each container runs MongoDB on port 27017 internally, but they're accessible on your host at different ports!
Understanding Volume Mounting (-v flag):
Docker containers are ephemeral by default - when you delete a container, all data inside it is lost. To persist data, we use volume mounts to store data on the host machine.
The -v flag mounts a directory from your host machine into the container, creating persistent storage.
Format: -v HOST_PATH:CONTAINER_PATH
- HOST_PATH: Directory on your computer (creates if doesn't exist)
- CONTAINER_PATH: Directory inside the container
After running this command, check your current directory - you'll see a new mongodb-data folder containing all MongoDB files. This ensures that your database data persists even if the container is deleted or recreated.
Now run Mongo Express, a web-based MongoDB admin interface:
docker run -d \
-p 10001:8081 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=password \
-e ME_CONFIG_MONGODB_SERVER=mongodb \
--net mongo-network \
--name mongo-express \
mongo-expressWhat this command does:
-p 10001:8081: Maps port 10001 from your host to container port 8081. This allows your browser on the host machine to access the web interface running inside the isolated container- Left side (10001): Port on your host - access the web UI at
localhost:10001 - Right side (8081): Port inside the container where Mongo Express web server listens
- Why 10001? We're using a custom port range (10000-series) for Part 1 to avoid conflicts with other parts of the tutorial
-e ME_CONFIG_MONGODB_SERVER=mongodb: Connects to the MongoDB container using the name "mongodb"- Note: Mongo Express doesn't need to connect to MongoDB through
localhost:10000because both containers are on the same Docker network. Container-to-container communication uses service names directly and the default container port (27017)!
- Left side (10001): Port on your host - access the web UI at
- Uses the same credentials we set for MongoDB
Understanding Port Mapping in This Setup:
- Your browser →
localhost:10001→ (port mapping) → Container's Mongo Express on port 8081 - Mongo Express →
mongodb:27017→ (Docker network) → Container's MongoDB on port 27017 - Your Node.js app (on host) →
localhost:10000→ (port mapping) → Container's MongoDB on port 27017
📝 Note: Notice that Mongo Express connects to MongoDB using the container name
mongodb, notlocalhost:27017. This is because both containers are on the same Docker network, so they can communicate directly using container names as hostnames. Port mapping is only needed for host-to-container communication!
Understanding docker images and docker ps
Now let's inspect what Docker has created using two essential commands:
docker images: Lists all downloaded/built Docker images on your systemdocker ps: Lists running containers (add-ato see all containers, including stopped ones)
List all downloaded Docker images:
docker imagesYou should see:
mongo- The MongoDB database imagemongo-express- The Mongo Express web UI image
List running containers:
docker psYou should see both containers running:
mongodb- Running on port 10000 (host) → 27017 (container)mongo-express- Running on port 10001 (host) → 8081 (container)
What information does docker ps show?
CONTAINER ID- Unique identifier for the containerIMAGE- Which image the container was created fromCOMMAND- The command running inside the containerCREATED- When the container was createdSTATUS- Whether it's running and for how longPORTS- Port mappings (host:container)NAMES- The name you assigned (or Docker generated)
Open Mongo Express in your browser:
http://localhost:10001
☁️ Using GitHub Codespaces? If you're working in Codespaces, don't use
localhost. Instead, go to the Ports tab in VS Code, find port 10001, and click the URL link to access the forwarded port. Note: If you see HTTP ERROR 404, wait 5-10 seconds for port forwarding to initialize, then refresh.
Login with the username "admin" and password "pass"
Navigate to the app directory and start the server:
cd app
npm install
node server.jsThe application will start on port 3000 and automatically connect to MongoDB at localhost:10000. The application automatically creates the database and collection if they don't exist!
Open your web browser and navigate to:
http://localhost:3000
☁️ Using GitHub Codespaces?
- Go to the Ports tab in VS Code (bottom panel)
- Find port 3000 in the list
- Click the globe icon 🌐 or the forwarded URL to open the app
- If you see "HTTP ERROR 404": This is normal! Codespaces port forwarding takes 5-10 seconds to initialize. Simply wait 10 seconds and refresh the page.
- Tip: You can check if the server is ready by adding
/healthto the URL (e.g.,https://your-url.app.github.dev/health). When it returns{"status":"ok"}, the app is ready.
Now play the Docker Quiz Challenge.
While the quiz is open in one browser tab, keep Mongo Express open in another tab:
- Go back to Mongo Express at
http://localhost:10001(or your Codespaces forwarded URL) - Navigate to:
quiz-db→scorescollection - Click the "scores" collection to view documents
- Submit a quiz in your quiz app
- Refresh the Mongo Express page
- You'll see a new document with your score, name, and timestamp!
- Check the
mongodb-datafolder in your project directory - you'll see the actual database files!
Let's demonstrate that your data is truly persistent thanks to the volume mount.
Stop the Node.js application:
Go to the terminal where node server.js is running and press Ctrl+C to stop it.
Stop and remove the MongoDB container (but NOT Mongo Express yet):
docker stop mongodb
docker rm mongodbCheck the data folder - it's still there!
ls -la mongodb-data/You'll see all the MongoDB data files are preserved on your host machine.
Restart MongoDB with the same volume:
docker run -d \
-p 10000:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
-v $(pwd)/mongodb-data:/data/db \
--name mongodb \
--net mongo-network \
mongoAccess Mongo Express again at http://localhost:10001 and navigate to quiz-db → scores.
All your quiz scores are still there! This demonstrates the power of volume mounting - your data survived the container being deleted and recreated.
Keep the database and Mongo Express running - we'll use them in Part 2 when we containerize the quiz application.
Stop the Node.js app if it's still running (press Ctrl+C).
In Part 1, you ran pre-built images from Docker Hub (mongo and mongo-express). Now let's learn how to create your own custom Docker image for the quiz application.
Here is the diagram of the architecture we'll set up:
A Dockerfile is a text file containing instructions to build a Docker image. It's like a recipe that tells Docker how to package your application.
Let's look at the Dockerfile in the repository root. Open it and you'll see:
FROM node:13-alpine
ENV MONGO_DB_USERNAME=admin \
MONGO_DB_PWD=password
RUN mkdir -p /home/app
COPY ./app /home/app
WORKDIR /home/app
RUN npm install
CMD ["node", "server.js"]Understanding Each Instruction:
Specifies the base image. Every Dockerfile must start with FROM.
node:13-alpineis a Node.js 13 image based on Alpine Linux- Alpine Linux is a minimal Linux distribution (~5MB) that creates smaller images
- Example:
node:13-alpineis ~50MB vsnode:13at ~500MB
Sets environment variables inside the container.
- These variables can be used by the application at runtime
- Format:
ENV KEY=value
Executes commands during the build process.
- Creates a directory in the image
RUNis used for installing packages, creating directories, etc.- Each
RUNcreates a new layer in the image
Copies files from your host machine into the image.
- Left side (
./app): Source path on your host - Right side (
/home/app): Destination path in the image
Sets the working directory for subsequent instructions.
- All following commands (
RUN,CMD) will execute from this directory - Like doing
cd /home/appin a terminal
Installs Node.js dependencies during the build.
- Reads
package.jsonand installs all required packages - Key point: This happens at build time, not when the container starts
Specifies the command to run when the container starts.
- Only the last
CMDin a Dockerfile takes effect - This is the entry point for your application
- Key Difference:
RUNexecutes at build time,CMDexecutes at container runtime
Understanding docker build
The docker build command builds a Docker image from a Dockerfile. It reads the instructions and creates an image layer by layer.
From the repository root folder, run:
docker build -t my-quiz-app:1.0 .What this command does:
docker build: The build command-t my-quiz-app:1.0: Tags the image with a name and versionmy-quiz-app: Image name1.0: Version tag (you can use any versioning scheme)
.: Build context (current directory) - Docker looks for the Dockerfile here
Watch the build process: You'll see Docker executing each instruction in the Dockerfile:
- Pulling the base image (
node:13-alpine) - Creating directories
- Copying files
- Installing dependencies
- Setting the startup command
List all Docker images on your system:
docker imagesYou should see your newly built image:
my-quiz-appwith tag1.0- Notice the image size - Alpine-based images are much smaller!
Check that MongoDB and Mongo Express are still running from Part 1:
docker psYou should see:
mongodb- Running on port 10000mongo-express- Running on port 10001
If they're not running, start them again:
docker run -d \
-p 10000:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
-v $(pwd)/mongodb-data:/data/db \
--name mongodb \
--net mongo-network \
mongo
docker run -d \
-p 10001:8081 \
-e ME_CONFIG_MONGODB_ADMINUSERNAME=admin \
-e ME_CONFIG_MONGODB_ADMINPASSWORD=password \
-e ME_CONFIG_MONGODB_SERVER=mongodb \
--net mongo-network \
--name mongo-express \
mongo-expressYour database and collection from Part 1 should still exist! If you visit Mongo Express at http://localhost:10001:
- Database
quiz-dbshould exist - Collection
scoresshould exist (may already have data from Part 1)
Now run a container from your custom image:
docker run -d \
-p 3000:3000 \
-e MONGO_HOST=mongodb \
-e MONGO_PORT=27017 \
-e MONGO_USER=admin \
-e MONGO_PASSWORD=password \
--name quiz-app \
--net mongo-network \
my-quiz-app:1.0What this command does:
- Runs your custom
my-quiz-app:1.0image -p 3000:3000: Maps port 3000 (the app listens on port 3000 internally)- Environment variables configure MongoDB connection:
MONGO_HOST=mongodb- Uses the container name on the Docker networkMONGO_PORT=27017- Uses the internal container port (not the host port!)MONGO_USER=adminandMONGO_PASSWORD=password- MongoDB credentials
--net mongo-network: Connects to the same network as MongoDB- Key Concept: Containers on the same network communicate using service names and internal ports, not host ports!
- The
CMD ["node", "server.js"]from your Dockerfile runs automatically
Open your browser to:
http://localhost:3000
☁️ Using GitHub Codespaces? Use the forwarded URL from the Ports tab for port 3000.
Congratulations! Your application now runs entirely in containers:
- ✅ MongoDB in a container (port 10000 on host)
- ✅ Mongo Express in a container (port 10001 on host)
- ✅ Quiz app in a container (port 3000 on host) - your custom image!
All three containers communicate via the mongo-network Docker network!
Verify all three containers are running:
docker psYou should see:
mongodb- Port mapping: 10000→27017mongo-express- Port mapping: 10001→8081quiz-app- Port mapping: 3000→3000
Understanding docker logs
To troubleshoot or monitor your containers, use docker logs:
docker logs quiz-appThis shows all output from your application, including:
- Startup messages
- MongoDB connection status (should show "✅ MongoDB Connection Successful")
- Database and collection creation confirmation
- Any errors or warnings
Check the logs to confirm database setup:
✅ MongoDB Connection Successful
✅ Database 'quiz-db' and collection 'scores' created successfully
Open Mongo Express at http://localhost:10001 and verify:
- Navigate to the databases list
- You should see
quiz-dbdatabase (created automatically by the app) - Click on
quiz-db - You should see
scorescollection (created automatically by the app)
💡 Note: The containerized app automatically created these on startup. No manual setup required!
Access the quiz at http://localhost:3000 and play a few rounds. Then:
- Open Mongo Express at
http://localhost:10001 - Navigate to
quiz-db→scores - See all your scores (including any from Part 1!)
All data is persisted in the mongodb-data folder on your host.
Now let's clean up the containers to prepare for Docker Compose (which will manage everything for us).
Stop and remove all containers:
docker rm -f mongodb mongo-express quiz-appRemove the network:
docker network rm mongo-network💡 Important: Notice we're NOT deleting the
mongodb-datafolder! Your quiz scores are safely stored there. In Part 3, we'll use Docker Compose with different ports to show how you can run multiple environments simultaneously.
Key Takeaways from Part 2:
- Dockerfiles define how to build custom images
docker buildcreates images from DockerfilesRUNexecutes at build time,CMDexecutes at runtime- Alpine-based images are smaller and faster
- Containerized apps connect to other containers using service names (not
localhost) - All three parts of our application (database, admin UI, app) can run in containers
In Parts 1 and 2, you manually ran multiple docker run commands for each container. This works, but it's tedious and error-prone. Docker Compose solves this by letting you define all services in a single file and manage them with simple commands.
Here is the diagram of the architecture we'll set up.
Docker Compose is a tool for defining and running multi-container applications. Instead of multiple docker run commands, you write a YAML file that describes your entire application stack.
Key Benefits:
- Define multiple services in one file
- Start/stop all services with one command
- Automatic network creation
- Automatic service name resolution (DNS)
- Environment variables and volumes managed in one place
The docker-compose up command reads your docker-compose.yaml file and:
- Creates networks automatically
- Starts all services in the correct order
- Links them together
- Shows combined logs from all services
Before we run Docker Compose, let's examine the docker-compose.yaml file in the repository root. The file has been configured to use different ports for Part 3.
Here's what the docker-compose.yaml file looks like:
version: '3'
services:
my-app:
build: .
ports:
- 3001:3000
environment:
- MONGO_HOST=mongodb
- MONGO_PORT=27017
- MONGO_USER=admin
- MONGO_PASSWORD=password
depends_on:
- mongodb
mongodb:
image: mongo
ports:
- 20000:27017
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=password
volumes:
- mongo-data:/data/db
mongo-express:
image: mongo-express
restart: always
ports:
- 20001:8081
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=password
- ME_CONFIG_MONGODB_SERVER=mongodb
depends_on:
- "mongodb"
volumes:
mongo-data:
driver: localversion: '3'
- Specifies the Docker Compose file format version
services:
- Defines all the containers (services) in our application
mongodb: service
image: mongo- Uses the official MongoDB image from Docker Hubports: - 20000:27017- Maps host port 20000 to container port 27017- Left (20000): Port on your host machine - access at
localhost:20000 - Right (27017): Port inside the MongoDB container
- Why 20000? We use port 20000 for Part 3 to avoid conflicts with Part 1 (which used 10000). This allows you to run both setups simultaneously!
- Why needed? If you want to connect to MongoDB from your host machine (e.g., using a database client)
- Left (20000): Port on your host machine - access at
environment:- Sets environment variables inside the containerMONGO_INITDB_ROOT_USERNAME=admin- Creates admin userMONGO_INITDB_ROOT_PASSWORD=password- Sets admin password
volumes: - mongo-data:/data/db- Mounts a named volume for data persistence- Left side (
mongo-data): The volume name - Right side (
/data/db): Where MongoDB stores data inside the container
- Left side (
mongo-express: service
image: mongo-express- Uses the Mongo Express web UI imagerestart: always- Automatically restarts if the container crashesports: - 20001:8081- Maps host port 20001 to container port 8081- Left (20001): Port on your host machine - access at
localhost:20001 - Right (8081): Port inside the container where Mongo Express web server listens
- Why 20001? Consistent with Part 3's port range (20000-series), avoiding conflicts with Part 1 (10000-series)
- Left (20001): Port on your host machine - access at
environment:- Configuration to connect to MongoDBME_CONFIG_MONGODB_ADMINUSERNAME=admin- MongoDB credentialsME_CONFIG_MONGODB_ADMINPASSWORD=password- Must match MongoDB settingsME_CONFIG_MONGODB_SERVER=mongodb- Uses service name for connection- Important: Containers communicate using service names as hostnames!
depends_on: - "mongodb"- Ensures MongoDB starts before Mongo Express
my-app: service (NEW!)
image: my-quiz-app:1.0- Uses the custom image we built in Part 2ports: - 3001:3000- Maps host port 3001 to container port 3000- Left (3001): Port on your host - access the quiz at
localhost:3001 - Right (3000): Port inside the container where the Node.js app listens
- Why 3001? Different from Part 2's port 3000, allowing both to run simultaneously if needed
- Left (3001): Port on your host - access the quiz at
environment:- Configuration for the appMONGO_HOST=mongodb- MongoDB service name (container-to-container communication)MONGO_PORT=27017- Internal MongoDB port (not the host port 20000!)MONGO_USER=admin- MongoDB usernameMONGO_PASSWORD=password- MongoDB password- The app will connect to MongoDB using
mongodb:27017(service name and internal port)
depends_on: - "mongodb"- Ensures MongoDB starts before the app
volumes: (at the bottom)
mongo-data:- Defines a named volumedriver: local- Stores data on the local filesystem- Why volumes? Data persists even when containers are deleted
Understanding Docker Volumes:
Volumes persist data beyond the container lifecycle. Without volumes, data is lost when a container is deleted.
Benefits:
- Store database data permanently
- Share files between host and container
- Share data between containers
In our example, MongoDB data is stored in the mongo-data volume, so even if you delete the container, your quiz scores remain safe!
Note: This is a Docker-managed named volume (different from the -v $(pwd)/mongodb-data:/data/db bind mount we used in Part 1). Named volumes are stored in Docker's data directory, not your current folder.
From the repository root, run:
docker-compose upThis single command:
- Creates a network automatically
- Starts MongoDB (port 20000)
- Starts Mongo Express (port 20001)
- Starts the Quiz App (port 3001)
- Links them all together
💡 Tip: Add
-dflag to run in detached mode:docker-compose -f docker-compose.yaml up -d
Start a new terminal. Examine the containers created by Docker Compose:
docker psNotice the container names now have a prefix
- Names containers based on the project directory and service name
- Creates a default network for all services
- Manages the lifecycle of all services together
You should see three containers:
developing-with-docker_mongodb_1- Port mapping: 20000→27017developing-with-docker_mongo-express_1- Port mapping: 20001→8081developing-with-docker_my-app_1- Port mapping: 3001→3000
Check the network created by Docker Compose:
docker network lsYou'll see a network named something like developing-with-docker_default - Docker Compose created this automatically!
Open your browser to:
http://localhost:20001
☁️ Using GitHub Codespaces? Find the forwarded URL for port 20001 in the Ports tab. If you see HTTP ERROR 404, wait a few seconds and refresh.
Notice the port is 20001 (Part 3 uses the 20000-series ports).
Login with the username "admin" and password "pass".
The quiz application is already running! Docker Compose started all three services together.
Access the application at:
http://localhost:3001
☁️ Using GitHub Codespaces? Use the forwarded URL from the Ports tab for port 3001. If you see HTTP ERROR 404, wait 5-10 seconds and refresh the page.
Notice the port is 3001 (not 3000 like in Part 2). This is Part 3's port configuration!
When the app starts, it will automatically create the quiz-db database and scores collection if they don't exist.
Check the application logs to see the database initialization:
docker logs developing-with-docker_my-app_1Open Mongo Express at http://localhost:20001 and verify:
- Navigate to the databases list
- You should see
quiz-dbdatabase (created automatically) - Click on
quiz-db - You should see
scorescollection (created automatically)
💡 Note: The app automatically creates the database and collection on startup. Since we're using a new Docker-managed volume, this is a fresh database separate from Part 1's data.
Interactive Learning Exercise:
-
Open two browser tabs:
- Tab 1: Quiz app at
localhost:3001(or forwarded URL) - Tab 2: Mongo Express at
localhost:20001(or forwarded URL)
- Tab 1: Quiz app at
-
In Mongo Express (Tab 2):
- Navigate to
quiz-db→scorescollection - Keep this tab open to watch database changes
- Navigate to
-
In Quiz App (Tab 1):
- Enter your name and start the quiz
- Answer all 10 Docker questions
- Submit your quiz
-
Back to Mongo Express (Tab 2):
- Refresh the page
- Observe: A new document appears with your score!
- Notice the fields:
name,score,totalQuestions,percentage,timestamp
-
Repeat the process:
- Play the quiz again with a different name
- Watch new score documents appear in real-time
- See how the leaderboard ranks players by score
This hands-on exercise demonstrates how Docker containers work together: the Node.js app processes quiz submissions and writes data to MongoDB, all while you observe the changes through Mongo Express!
To stop all services:
docker-compose downThis stops and removes all containers. Your data persists in the Docker volume.
Key Takeaways from Part 3:
- Docker Compose manages multi-container applications with a single YAML file
docker-compose upstarts all services;docker-compose downstops them- Services communicate using service names as hostnames
- Port mapping format:
HOST_PORT:CONTAINER_PORT - Volumes preserve data across container lifecycles
depends_oncontrols startup order- Docker Compose automatically creates networks and manages container lifecycle
Here's a quick reference of all Docker commands covered in this tutorial:
docker run - Create and start a container
docker run -d -p 3000:3000 --name my-app --net my-network my-image:1.0docker build - Build an image from a Dockerfile
docker build -t my-app:1.0 .docker ps - List running containers (use -a for all)
docker ps
docker ps -adocker images - List all images
docker imagesdocker logs - View container logs
docker logs container-namedocker rm - Remove containers (use -f to force)
docker rm -f container-namedocker network create - Create a network
docker network create my-networkdocker network ls - List networks
docker network lsdocker-compose up - Start services from docker-compose.yaml
docker-compose up
docker-compose up -d # detached modedocker-compose down - Stop and remove all services
docker-compose down











