How to create Containers with docker
- Sharon Rajendra Manmothe

- 18 hours ago
- 1 min read
Create a folder:
simple-docker-app
Inside it, create 3 files:
simple-docker-app/
├── app.py
├── requirements.txt
└── Dockerfile
Step 2 — app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello! This app is running inside a Docker container."
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)
Step 3 — requirements.txt
flask
Step 4 — Dockerfile
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
Step 5 — Build Docker Image
Open terminal in this folder:
docker build -t simpleapp:v1 .
Check image:
docker images
Step 6 — Run Container
docker run -p 5000:5000 simpleapp:v1
Step 7 — Open in Browser
Open:
You will see:
Hello! This app is running inside a Docker container.
Container 1 — Nginx Website (HTML only)
Files
nginx-app/
└── index.html
index.html
<h1>Nginx running inside Docker</h1>
Dockerfile
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
Build & Run
docker build -t nginxapp .
docker run -p 8080:80 nginxapp
Open: http://localhost:8080
Container 2 — Python Script Container (prints output)
Files
python-script/
├── script.py
└── Dockerfile
print("Python running inside Docker container")
Dockerfile
FROM python:3.10-slim
COPY script.py .
CMD ["python", "script.py"]
Build & Run
docker build -t pyscript .
docker run pyscript
Container 3 — Node.js Web App
Files
node-app/
├── app.js
└── Dockerfile
app.js
const http = require('http');
http.createServer((req,res)=>{
res.write("Node.js app in Docker");
res.end();
}).listen(3000);
Dockerfile
FROM node:18-alpine
COPY app.js .
CMD ["node", "app.js"]
Build & Run
docker build -t nodeapp .
docker run -p 3000:3000 nodeapp
Open: http://localhost:3000
Container 4 — MySQL Database Container
(No files needed)
Run directly
docker run -d \
--name mysqlcontainer \
-e MYSQL_ROOT_PASSWORD=root123 \
-p 3306:3306 \
mysql:8
Check running:
docker ps

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.




Comments