First basic container
app.py
from flask import Flask, Response, send_file
import os
app = Flask(__name__)
@app.route('/')
def hello():
return "Docker is Awesome!"
@app.route('/logo')
def docker_logo():
return send_file('docker-logo.png', mimetype='image/png')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
docker-logo.png:

requirements.txt
Dockerfile:
#Creates a new layer with the base image python:3.14.0a3-alpine3.21
FROM python:3.14.0a3-alpine3.21
#Creates a new layer with the working directory /app
WORKDIR /app
#Environment variable that will be set in the container by default
ENV APP_ENV="SomeVariable"
#Creates a new layer by copying files app.py, docker-logo.png, requirements.txt to the working directory /app
COPY app.py .
COPY docker-logo.png .
COPY requirements.txt .
#Creates a new layer by running the command pip install -r requirements.txt
RUN pip install -r requirements.txt
#Does not create a new layer, but runs the EXPOSE 8080 command which adds metadata
EXPOSE 8080
#Does not create a new layer, but runs the ENTRYPOINT ["python", "app.py"] command which specifies how to start the container
ENTRYPOINT ["python", "app.py"]
Let's break down each instruction:
FROM python:3.14.0a3-alpine3.21specifies the base Image;WORKDIR /appsets the working directory inside the container;COPY app.py .andCOPY docker-logo.png .copy the application code to the container;RUN pip install flaskinstalls theFlasklibrary;EXPOSE 8080sets port8080;ENTRYPOINT ["python", "app.py" ]sets the application startup command.
Layers should be created from least frequently changed to most frequently changed, because when rebuilding a container, layers that have not been modified are pulled from cache.
Then run in terminal:
-t - key to specify image name : tag . - path where program files are located relative to point where we execute docker build
Run it with:
If name of dockerfile is not "Dockerfile" but something else, you should specify -f key with name: