Skip to main content
Video·youtube.com
devopsinfrastructurepythonweb-developmentautomationcloud-functionsdeploymentdockerdocker-composeflasksolarputtyraspberry-pi

you need to learn Docker RIGHT NOW!! // Docker Containers 101

Containerize a simple Python Flask app using Docker. Learn to build images, run containers, and orchestrate with Docker Compose for consistent, portable application deployment. This pack provides hands-on steps to get your web app running in an isolated environment quickly.

beginner15 min6 steps
The play
  1. Create your Flask application files
    In a new directory, create `app.py` and `requirements.txt` with the provided Flask code and dependencies.
  2. Define your Dockerfile
    Create a `Dockerfile` in the same directory. This file instructs Docker on how to build your application's image, including base image, dependencies, and execution command.
  3. Build the Docker image
    Open your terminal in the directory containing your files and run the `docker build` command to create your application's image. The `-t` flag tags the image with a name.
  4. Run the Docker container
    Launch your Flask application in an isolated container using the `docker run` command. The `-p 5000:5000` flag maps port 5000 from your host machine to port 5000 inside the container.
  5. Access your application
    Open a web browser and navigate to `http://localhost:5000` to verify your Flask app is running inside the Docker container. You should see the 'Hello from Docker!' message.
  6. Orchestrate with Docker Compose (Optional)
    For simplified multi-service management, create a `docker-compose.yml` file in your project root. This allows you to build and run your services with a single command.
Starter code
FROM python:3.9-slim-buster
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "app.py"]
Source
you need to learn Docker RIGHT NOW!! // Docker Containers 101 — Action Pack