在 Alpine Linux Docker 容器中安装 ODBC 驱动程序 [英] Install ODBC driver in Alpine Linux Docker Container
问题描述
我目前有以下 Dockerfile
来创建我的 Docker 映像.
I currently have the following Dockerfile
to create my Docker image.
FROM python:3.6.6-alpine3.8
# Add dependencies for Python packages pandas, numpy and pyodbc
RUN apk add --no-cache curl gcc g++ unixodbc-dev
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
# Project files
ARG PROJECT_DIR=/srv/scripts
RUN mkdir -p $PROJECT_DIR
WORKDIR $PROJECT_DIR
COPY requirements.txt ./
# Install Python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
我想在此映像中包含各种 ODBC 驱动程序,以便我可以使用它们从运行在我的容器中的 Python 程序连接到不同的数据库.
I would like to include various ODBC drivers in this image so that I can use them to connect to different databases from the Python program running in my container.
- Python 程序正在使用
Pyodbc
连接数据库. - 我需要安装的 ODBC 驱动程序是:
- PostgreSQL
- MySQL
- SQL Server 女士
- Teradata
- 甲骨文
- 蜂巢
- 黑斑羚
我想从 PostgreSQL 开始,认为它是最简单的,但我在 Alpine Linux 上找不到任何软件包包管理器.你知道我应该如何安装这样的驱动程序吗?
I wanted to start with PostgreSQL thinking it would be the easiest one but I could not find any package on the Alpine Linux Package manager. Do you have any idea how I should install such a driver?
推荐答案
我也遇到了同样的问题.我通过在
RUN apk add
命令之前添加RUN apk update
解决了这个问题.(我使用的是 python:3.6-alpine)I was facing the same issue. I solved this issue by adding
RUN apk update
beforeRUN apk add
commands.(I was using python:3.6-alpine)Dockerfile
FROM python:3.6-alpine RUN apk update RUN apk add gcc libc-dev g++ libffi-dev libxml2 unixodbc-dev mariadb-dev postgresql-dev
这篇关于在 Alpine Linux Docker 容器中安装 ODBC 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!