docker 将管道安装在对接器中

zaq34kh6  于 2023-01-12  发布在  Docker
关注(0)|答案(6)|浏览(106)

我无法在Docker中安装pip。
下面是我的Dockerfile:

FROM ubuntu:14.04

# Install dependencies
RUN apt-get update -y
RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql python3.4 python-pip

构建时,我得到:

Sending build context to Docker daemon 109.6 kB
Step 1 : FROM ubuntu:14.04
 ---> b549a9959a66
Step 2 : RUN apt-get update -y
 ---> Using cache
 ---> 84577471562c
Step 3 : RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql python3.4 python-pip
 ---> Running in 49252a6d0eb1
Reading package lists...
Building dependency tree...
Reading state information...
python3.4 is already the newest version.
The following extra packages will be installed:
  apache2-bin apache2-data binutils build-essential ca-certificates cpp
  cpp-4.8 dpkg-dev fakeroot g++ g++-4.8 gcc gcc-4.8 git-man krb5-locales
  libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libasan0
  libasn1-8-heimdal libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libcurl3
  libcurl3-gnutls libdpkg-perl libedit2 liberror-perl libfakeroot
  libfile-fcntllock-perl libgcc-4.8-dev libgmp10 libgomp1 libgssapi-krb5-2
  libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
  libheimntlm0-heimdal libhx509-5-heimdal libidn11 libisl10 libitm1
  libk5crypto3 libkeyutils1 libkrb5-26-heimdal libkrb5-3 libkrb5support0
  libldap-2.4-2 libmcrypt4 libmpc3 libmpfr4 libmysqlclient18 libpython-stdlib
  libpython2.7-minimal libpython2.7-stdlib libquadmath0 libroken18-heimdal
  librtmp0 libsasl2-2 libsasl2-modules libsasl2-modules-db libstdc++-4.8-dev
  libtimedate-perl libtsan0 libwind0-heimdal libx11-6 libx11-data libxau6
  libxcb1 libxdmcp6 libxext6 libxml2 libxmuu1 linux-libc-dev lsof make
  manpages manpages-dev mysql-common openssh-client openssl patch php5-cli
  php5-common php5-json php5-readline psmisc python python-chardet
  python-chardet-whl python-colorama python-colorama-whl python-distlib
  python-distlib-whl python-html5lib python-html5lib-whl python-minimal
  python-pip-whl python-pkg-resources python-requests python-requests-whl
  python-setuptools python-setuptools-whl python-six python-six-whl
  python-urllib3 python-urllib3-whl python-wheel python2.7 python2.7-minimal
  python3-pkg-resources rsync sgml-base ssl-cert xauth xml-core xz-utils
Suggested packages:
  www-browser apache2-doc apache2-suexec-pristine apache2-suexec-custom ufw
  apache2-utils binutils-doc cpp-doc gcc-4.8-locales debian-keyring
  g++-multilib g++-4.8-multilib gcc-4.8-doc libstdc++6-4.8-dbg gcc-multilib
  autoconf automake1.9 libtool flex bison gdb gcc-doc gcc-4.8-multilib
  libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan0-dbg
  libtsan0-dbg libquadmath0-dbg gettext-base git-daemon-run
  git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch
  git-bzr git-cvs git-mediawiki git-svn php-pear glibc-doc krb5-doc krb5-user
  libmcrypt-dev mcrypt libsasl2-modules-otp libsasl2-modules-ldap
  libsasl2-modules-sql libsasl2-modules-gssapi-mit
  libsasl2-modules-gssapi-heimdal libstdc++-4.8-doc make-doc man-browser
  ssh-askpass libpam-ssh keychain monkeysphere ed diffutils-doc
  php5-user-cache python-doc python-tk python-genshi python-lxml
  python-distribute python-distribute-doc python2.7-doc binfmt-support
  python3-setuptools openssh-server sgml-base-doc openssl-blacklist debhelper
Recommended packages:
  ssh-client python-dev-all
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data binutils build-essential ca-certificates
  cpp cpp-4.8 curl dpkg-dev fakeroot g++ g++-4.8 gcc gcc-4.8 git git-man
  krb5-locales libalgorithm-diff-perl libalgorithm-diff-xs-perl
  libalgorithm-merge-perl libapache2-mod-php5 libapr1 libaprutil1
  libaprutil1-dbd-sqlite3 libaprutil1-ldap libasan0 libasn1-8-heimdal
  libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libcurl3 libcurl3-gnutls
  libdpkg-perl libedit2 liberror-perl libfakeroot libfile-fcntllock-perl
  libgcc-4.8-dev libgmp10 libgomp1 libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libisl10 libitm1 libk5crypto3 libkeyutils1
  libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libmcrypt4
  libmpc3 libmpfr4 libmysqlclient18 libpython-stdlib libpython2.7-minimal
  libpython2.7-stdlib libquadmath0 libroken18-heimdal librtmp0 libsasl2-2
  libsasl2-modules libsasl2-modules-db libstdc++-4.8-dev libtimedate-perl
  libtsan0 libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6
  libxext6 libxml2 libxmuu1 linux-libc-dev lsof make manpages manpages-dev
  mysql-common openssh-client openssl patch php5 php5-cli php5-common
  php5-json php5-mcrypt php5-mysql php5-readline psmisc python python-chardet
  python-chardet-whl python-colorama python-colorama-whl python-distlib
  python-distlib-whl python-html5lib python-html5lib-whl python-minimal
  python-pip python-pip-whl python-pkg-resources python-requests
  python-requests-whl python-setuptools python-setuptools-whl python-six
  python-six-whl python-urllib3 python-urllib3-whl python-wheel python2.7
  python2.7-minimal python3-pkg-resources rsync sgml-base ssl-cert xauth
  xml-core xz-utils
0 upgraded, 130 newly installed, 0 to remove and 4 not upgraded.
Need to get 61.9 MB of archives.
After this operation, 213 MB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ trusty-updates/main libroken18-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1
  Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com/ubuntu/ trusty-updates/main libasn1-8-heimdal amd64 1.6~git20131207+dfsg-1ubuntu1.1
  Could not resolve 'archive.ubuntu.com'

.
.
.

Err http://archive.ubuntu.com/ubuntu/ trusty-security/main python2.7 amd64 2.7.6-8ubuntu0.2
  Could not resolve 'archive.ubuntu.com'
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/h/heimdal/libroken18-heimdal_1.6~git20131207+dfsg-1ubuntu1.1_amd64.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/h/heimdal/libasn1-8-heimdal_1.6~git20131207+dfsg-1ubuntu1.1_amd64.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkrb5support0_1.12+dfsg-2ubuntu5.2_amd64.deb  Could not resolve 'archive.ubuntu.com'

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/s/ssl-cert/ssl-cert_1.0.33_all.deb  Could not resolve 'archive.ubuntu.com'

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql python3.4 python-pip' returned a non-zero code: 100

读取this answer后,我尝试添加RUN "sh" "-c" "echo nameserver 8.8.8.8 >> /etc/resolv.conf"行-这次的错误是:

...
...
Reading state information...
E: Unable to locate package php5-mcrypt
E: Unable to locate package python-pip
The command '/bin/sh -c apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql python3.4 python-pip' returned a non-zero code: 100

我做错了什么?我看到一些人声称我应该尝试一个不同的Ubuntu版本,但是切换到13.1并没有改变什么。

ghhkc1vu

ghhkc1vu1#

虽然T. Arboreus's answer可能会解决解决“www.example.com”的问题archive.ubuntu.com,但我认为您收到的最后一个错误是它不知道php5-mcryptpython-pip包。尽管如此,只有这两个包的简化Dockerfile对我来说是有效的(使用Debian 8.4和Docker 1.11.0),但我不太确定是否会出现这种情况,因为我的主机系统与您的不同。

FROM ubuntu:14.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    php5-mcrypt \
    python-pip

然而,根据this answer,当使用Python 3.x时,你应该考虑安装python3-pip包而不是python-pip包。
此外,为了使php5-mcrypt包安装工作,您可能希望添加universe存储库,如right here所示。我遇到了Ubuntu Docker映像中缺少add-apt-repository命令的问题,因此我首先安装了software-properties-common包以使该命令可用。
here还建议将语句拆分并将apt-get updateapt-get install放入一个RUN命令中。
哦,顺便说一下,您实际上不需要apt-get update处的-y标志,因为没有什么需要自动确认的。

最后:

FROM ubuntu:14.04

# Install dependencies
RUN apt-get update && apt-get install -y \
    software-properties-common
RUN add-apt-repository universe
RUN apt-get update && apt-get install -y \
    apache2 \
    curl \
    git \
    libapache2-mod-php5 \
    php5 \
    php5-mcrypt \
    php5-mysql \
    python3.4 \
    python3-pip

备注:使用过的版本(例如Ubuntu)将来可能会过时。

blpfk2vs

blpfk2vs2#

这个命令对我来说很好用:

RUN apt-get -y install python3-pip
a8jjtwal

a8jjtwal3#

试试这个:
1.取消注解/etc/default/docker DOCKER_OPTS ="--dns www.example.com--dns www.example.com"中的以下行 8.8.8.8 --dns 8.8.4.4 "
1.重新启动Docker服务sudo服务Docker重新启动
1.删除缓存了无效DNS设置的所有映像。
1.再建一次,问题就应该解决了。
this question开始。

ippsafx7

ippsafx74#

您可能需要更改Docker守护程序的DNS设置。您可以使用dns密钥编辑(或创建)/etc/docker/daemon.json中的配置文件,如下所示

{
    "dns": ["your_dns_address", "8.8.8.8"]
}

在上面的例子中,列表的第一个元素是你的DNS服务器的地址,第二个元素是Google的DNS,当第一个元素不可用时可以使用它。
在继续之前,保存daemon.json并重新启动Docker服务。

sudo service docker restart

修复后,请重试运行生成命令。

6g8kf2rb

6g8kf2rb5#

另一种选择是使用Alpine Linux容器,例如python:2.7-alpine。它们提供开箱即用的pip(占用空间较小,但要注意possible python problems)。

0ve6wy6x

0ve6wy6x6#

您可以尝试:sudo apt-get install python-pip python-dev

相关问题