我正在尝试建立一个可以在我的笔记本电脑上运行的 flask 应用程序的Docker映像。这个应用程序用于使用Python生成PostgreSQL转储。所以我需要添加pg_dump和libpq.so.5。请参见下面我的Docker文件:
FROM XXX/postgres:13.9-alpine as postgres
FROM XXX/python:3.8-alpine
USER root
WORKDIR /dump_generator_api
COPY requirements.txt ./
RUN python3 -m pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY --from=postgres /usr/local/bin/pg_dump /usr/local/bin/pg_dump
COPY --from=postgres /usr/local/lib/libpq.so.5 /usr/local/lib/libpq.so.5
ADD . /dump_generator_api
EXPOSE 5000
CMD ["python", "/dump_generator_api/app.py"]
构建映像后,我尝试应用pg_dump命令(/usr/local/bin # pg_dump -U pgsqladmin -h XXX -p XXX XXX〉backup.sql),但出现以下错误,我不明白:
Error loading shared library libldap.so.2: No such file or directory (needed by /usr/local/lib/libpq.so.5)
Error relocating /usr/local/lib/libpq.so.5: ldap_err2string: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_result: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_simple_bind: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_count_entries: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_unbind: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_set_option: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_search_st: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_value_free_len: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_get_values_len: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_first_entry: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_init: symbol not found
Error relocating /usr/local/lib/libpq.so.5: ldap_msgfree: symbol not found
你知道我该怎么解决这个问题吗?我尝试了不同的Docker图像,同样的错误出现了。我不知道我应该在哪里以及如何添加这个libldap.so.2.
1条答案
按热度按时间yiytaume1#
从postgres镜像复制pg_dump和libpq.so.5将不起作用,每个二进制文件依赖于其他包。
你应该使用“apk add postgresql”在你的镜像上安装postgres,它会和它需要的所有东西沿着安装。
该文件将类似于: