Program – 1 Build a Docker Container from a Custom Dockerfile Project Structure Program-1/ ├── Dockerfile ├── app.py └── requirements.txt Step 1: Create Project Directory Command: mkdir Program-1 cd Program-1 Step 2: Create Dockerfile Command: nano Dockerfile Content of Dockerfile: # This is a Dockerfile # Dockerfile is a set of instructions that Docker # uses to build a container image # Use a slim Python base image FROM python:3.9-slim # Set the working directory inside the container WORKDIR /app # Copy the requirements file and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the application code COPY . . # Set Flask environment variables ENV FLASK_APP=app.py ENV FLASK_RUN_HOST=0.0.0.0 ENV FLASK_RUN_PORT=5000 # Expose the port the Flask app will run on EXPOSE 5000 # Define the command to run the Flask application CMD ["flask", "run"] Step 3: Create Python Application File Command: nano app.py Content of app.py: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello, Docker!" if __name__ == "__main__": app.run(host="0.0.0.0", port=5000) Step 4: Create Requirements File Command: nano requirements.txt Content of requirements.txt: flask Step 5: Build Docker Image Command: docker build -t program-1 . Step 6: Verify Docker Image Command: docker images Step 7: Run Docker Container Command: docker run -d -p 5000:5000 --name flask-container program-1 Step 8: Verify Running Container Command: docker ps Step 9: Test the Application Open a web browser and enter: http://localhost:5000 Output: Hello, Docker! Step 10: Stop the Docker Container Command: docker container stop flask-container Step 11: Remove the Docker Container Command: docker container rm flask-container Step 12: Remove Docker Image Command: docker image rm program-1