
mkdir python-docker-app
cd python-docker-app
nano app.py
Paste the following:
print("Hello from Python Docker!")
Save → CTRL + X → Y → Enter
nano Dockerfile
Paste the following:
FROM python:3
COPY app.py /
CMD ["python", "/app.py"]
Save and exit (CTRL + X → Y → Enter)
| Dockerfile Line | Meaning |
|---|---|
| FROM python:3 | Use Python base image |
| COPY app.py / | Copy your app into container |
| CMD ["python", "/app.py"] | Run the app when container starts |
docker build -t pyapp .
-t pyapp → Names the image pyapp
docker run pyapp
Expected Output:
Hello from Python Docker!






