繁体   English   中英

无法建立python docker映像

[英]can't build python docker image

我正在尝试使用以下dockerfile构建python的docker映像:我希望具有最小的映像,因此我将elyase / conda:2.7映像用作基础:

 # Pull base image.
FROM elyase/conda:2.7
MAINTAINER me
RUN opkg-install --verbosity=4 curl python-dateutil python-botocore && \
    curl --no-verify-ssl https://bootstrap.pypa.io/get-pip.py && \
    python get-pip.py && \
    pip install --upgrade --user awscli && \
    pip install boto3 chardet patool

运行命令后:

docker build -t repository.test .

我收到此错误:

Sending build context to Docker daemon 26.11 kB
Step 1/10 : FROM elyase/conda:2.7
 ---> 4abdba6a4c51
Step 2/10 : MAINTAINER me
 ---> Using cache
 ---> 54b7c51ab2b9
Step 3/10 : VOLUME /tmp
 ---> Using cache
 ---> 491cf0da6c97
Step 4/10 : VOLUME /efs-script-import-tmp
 ---> Using cache
 ---> 1b3167c560e7
Step 5/10 : RUN opkg-install --verbosity=4 curl python-dateutil python-botocore &&     curl --no-verify-ssl https://bootstrap.pypa.io/get-pip.py &&     python get-pip.py &&     pip install --upgrade --user awscli &&     pip install boto3 chardet patool
 ---> Running in 009d37b86f48
wget: server returned error: HTTP/1.1 404 Not Found
wget: server returned error: HTTP/1.1 404 Not Found
Downloading http://downloads.openwrt.org/snapshots/trunk/x86_64/generic/packages/base/Packages.gz.
Downloading http://downloads.openwrt.org/snapshots/trunk/x86_64/generic/packages/packages/Packages.gz.
Collected errors:
 * opkg_download: Failed to download http://downloads.openwrt.org/snapshots/trunk/x86_64/generic/packages/base/Packages.gz, wget returned 1.
 * opkg_download: Failed to download http://downloads.openwrt.org/snapshots/trunk/x86_64/generic/packages/packages/Packages.gz, wget returned 1.
opkg_conf_parse_file: Loading conf file /etc/opkg.conf.
pkg_hash_load_feeds: 
pkg_hash_load_status_files: 
pkg_vec_insert_merge: Adding new pkg=terminfo version=5.9 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=libc version=0.9.33.2 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=bash version=4.3.30 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=bzip2 version=1.0.6 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=libgcc version=4.8-linaro arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=libncurses version=5.9 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=zlib version=1.2.8 arch=x86_64.
pkg_vec_insert_merge: Adding new pkg=libbz2 version=1.0.6 arch=x86_64.
opkg_install_cmd: curl
opkg_install_cmd: python-dateutil
opkg_install_cmd: python-botocore
pkg_info_preinstall_check: Updating file owner list.
**Unknown package 'curl'.
Unknown package 'python-dateutil'.**
**Unknown package 'python-botocore'.**
opkg_configure_packages: Configuring unpacked packages.
opkg_configure_packages: Reordering packages before configuring them...
opkg_recurse_pkgs_in_order: pkg terminfo.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc.
opkg_recurse_pkgs_in_order: Descending on pkg libgcc.
opkg_recurse_pkgs_in_order: pkg libgcc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: pkg bash.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: Descending on pkg libncurses.
opkg_recurse_pkgs_in_order: pkg libncurses.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: Descending on pkg terminfo.
opkg_recurse_pkgs_in_order: pkg terminfo already visited, skipping.
opkg_recurse_pkgs_in_order: pkg bzip2.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: Descending on pkg libbz2.
opkg_recurse_pkgs_in_order: pkg libbz2.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: pkg libgcc already visited, skipping.
opkg_recurse_pkgs_in_order: pkg libncurses already visited, skipping.
opkg_recurse_pkgs_in_order: pkg zlib.
opkg_recurse_pkgs_in_order: Descending on pkg libc.
opkg_recurse_pkgs_in_order: pkg libc already visited, skipping.
opkg_recurse_pkgs_in_order: pkg libbz2 already visited, skipping.
write_status_files_if_changed: Nothing to be done.
hash_table: pkg-hash, 24576 bytes
    n_buckets=1024, n_elements=8, n_collisions=0
    max_bucket_len=0, n_used_buckets=8, ave_bucket_len=1.00
    n_hits=10, n_misses=14
hash_table: file-hash, 24576 bytes
    n_buckets=1024, n_elements=60, n_collisions=2
    max_bucket_len=1, n_used_buckets=58, ave_bucket_len=1.03
    n_hits=0, n_misses=60
hash_table: obs-file-hash, 1536 bytes
    n_buckets=64, n_elements=0, n_collisions=0
    max_bucket_len=0, n_used_buckets=0, ave_bucket_len=0.00
    n_hits=0, n_misses=0
Collected errors:
 * opkg_install_cmd: Cannot install package curl.
 * opkg_install_cmd: Cannot install package python-dateutil.**
 * opkg_install_cmd: Cannot install package python-botocore.
/bin/sh: curl: not found**
The command '/bin/sh -c opkg-install --verbosity=4 curl python-dateutil python-botocore &&     curl --no-verify-ssl https://bootstrap.pypa.io/get-pip.py &&     python get-pip.py &&     pip install --upgrade --user awscli &&     pip install boto3 chardet patool' returned a non-zero code: 127

我不知道如何在其中安装应用程序所需的软件包

您现在使用的是旧的图像elyase / conda:2.7 ,它引用了http://downloads.openwrt.org/snapshots/trunk/x86_64/generic/packages ,但看起来现在是http://downloads.openwrt.org/snapshots / trunk / x86 / 64 / packages

您需要在/etc/opkg.conf修复此URL。

这是一个相对较小的映像(105M)的Dockerfile,几乎可以完成此工作:

FROM alpine

# Runtime packages
RUN apk add --no-cache py-numpy sqlite-libs \
# Build packages
 && apk add --no-cache --virtual .build-deps \
          py-pip \
          musl-dev g++ python-dev py-numpy-dev \
          ca-certificates \
# Runtime pip packages
 && pip install boto3 chardet patool \
# Pandas
 && pip install pandas \
# Cleaning
 && apk del .build-deps \
 && rm -rf /root/.cache/ /var/cache/misc/*

您可以修改它以安装所需的任何其他lib,或者使用pip安装numpy,这样就不会安装python,并且可以像以前一样使用pyrun

Unknown package 'awscli'.
Unknown package 'python-botocore'.

=>很清楚:'awscli'和'python-botocore'都不可用的openwrt包,我猜应该用pip安装它们

Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] unknown error (_ssl.c:661) -- Some packages may not be found!

=> 导致SSL的Alpine 3.3,Python 2.7.11,urllib2:CERTIFICATE_VERIFY_FAILED :您需要安装opkg软件包ca-certificates

但是,它将失败,因为它将尝试构建C代码,因此您必须安装python标头和co。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM