Certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

Issue type:

certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

Docker and Docker-Compose version

Install Docker Desktop on Windows

docker --version

Docker version 24.0.7, build afdd53b

Install Compose standalone

docker-compose --version

Docker Compose version v2.23.0

Issue Description
  • Dockerizing a Python application to run on Windows Server 2019 involves installing Docker and Docker Compose on the server.
  • Getting SSL certificate error since we are not using any private certificate for database connection.
  • The database in use is MS SQL 2017, and ODBC drivers are employed for accessing ODBC databases.
Docker Code

docker-compose.yml:

version: '3.8'
services:
  my-app:  
    build:
      context: . 
      dockerfile: Dockerfile
    env_file:
      - .env

Dockerfile:

# Use the official Microsoft Windows Server Core image with Python 3.9
FROM python:3.9-windowsservercore

# Set the working directory
WORKDIR /app

# Download and install MS SQL 2017 ODBC Driver
CMD ["cmd.exe", "curl https://go.microsoft.com/fwlink/?linkid=2249004"]
CMD ["cmd.exe", "msiexec", "/i", "msodbcsql.msi", "ADDLOCAL=ALL"]

# Copy just the requirements file
COPY requirements.txt requirements.txt

# Install the dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the current directory contents into the container at /app
COPY . /app

# Run the application
CMD ["python", "sms_main.py"]