- 3.1 Dockerfile
- 3.2 Containerize a Node.js Application
- 3.3 Automatic Port Mapping
- 3.4 Pushing to Docker Hub
- 4.1 Bridge Mode Networking
- 4.2 Host Mode Networking
- 4.3 Overlay Mode Networking
- 4.4 IPvlan and MacVlan Networking
- 4.5 None Mode Networking
- Definition: Docker is a platform for developing, shipping, and running applications inside lightweight, portable containers.
- Key Benefits:
- Consistency across environments
- Rapid application deployment
- Resource efficiency compared to traditional VMs
-
Steps to Install:
- Windows : Use Docker Desktop (CLI + GUI)
- Linux: Use package managers like
aptoryum - MacOS: Docker Desktop or brew install docker
-
Check Installation: Run
docker --version.
- Image: A lightweight, standalone, and executable software package.
- Container: An instance of an image running as an isolated process.
- Commands:
docker pull <image-name> docker run <image-name>
π§« Run Docker in WSL
- A cloud-based repository to store and share Docker images.
- Usage:
- Find public images
- Push custom images using
docker push
- Purpose: Manage images, containers, and Docker resources using the terminal.
- Basic Commands:
docker psβ List running containersdocker imagesβ List images
- Key Commands:
docker pull <image>β Download an imagedocker rmi <image>β Remove an image
- Key Commands:
docker run <image>β Start a containerdocker stop <container>β Stop a running containerdocker logs <container>β View logs from a container
- Definition: A text file containing instructions to build a Docker image.
- Sample Dockerfile:
FROM node:14 COPY . /app WORKDIR /app RUN npm install CMD ["node", "app.js"]
- Command to Build:
docker build -t <image-name> .
- Steps to:
- Create a
Dockerfile - Use
docker buildanddocker run
- Create a
- Map ports using
-pflag:docker run -p 3000:3000 <image>
- Authenticate:
docker login - Push Image:
docker tag <image> <username>/<repository> docker push <username>/<repository>
- Default mode. Containers share the host's networking but are isolated.
- Command:
docker network inspect bridge
- Shares the host network namespace.
- Useful for performance-critical apps.
- Enables multi-host container communication.
- Advanced networking modes for performance and integration.
- Completely disables networking for the container.
- Mount directories from the host into the container.
- Command:
docker run -v /host/path:/container/path <image>
- Named volumes for persistent storage:
docker volume create myvolume
- A tool to define and run multi-container Docker applications.
-
Sample
docker-compose.yml:version: '3' services: app: image: node:14 ports: - "3000:3000"
-
Commands:
docker-compose up docker-compose down
| Command | Description |
|---|---|
docker pull <image> |
Download an image |
docker run <image> |
Create and start a container |
docker ps |
List running containers |
docker stop <container> |
Stop a running container |
docker volume create |
Create a named volume |
| Networking Mode | Description |
|---|---|
| Bridge | Default mode, isolated container networking |
| Host | Shares host's network namespace |
| Overlay | For multi-host communication |





