Lin Minquan's Blog

Experience technology to change life

Building a Pytest Enabled Docker Image Using Python Base Image

Attempting to create a Docker image based on Python and install the dependencies required for Pytest.

Windows systems require installing WSL2 and Docker Desktop.

Create a file called Dockerfile in the project root directory with the following content:

FROM python:3.12.11-slim

RUN apt-get update && apt-get install -y curl unzip wget

# Install Java (required for Allure)
RUN apt-get install -y default-jre-headless

# Install Allure Report
RUN wget https://github.com/allure-framework/allure2/releases/download/2.32.0/allure_2.32.0-1_all.deb && \
    dpkg -i allure_2.32.0-1_all.deb || true && \
    apt --fix-broken install -y && \
    rm allure_2.32.0-1_all.deb

# Install Aliyun OSS CLI
RUN curl https://gosspublic.alicdn.com/ossutil/install.sh | bash

Build the image: docker build -t leopytest:latest .

Publish to Docker Hub:

# Tag your image
docker tag your-image-name your-dockerhub-username/your-image-name:tag

# Login to Docker Hub
docker login

# Push to Docker Hub
docker push your-dockerhub-username/your-image-name:tag

Translations


Share