![无法在 docker 中找到软件包 libc6-dbg:i386](https://linux22.com/image/1122967/%E6%97%A0%E6%B3%95%E5%9C%A8%20docker%20%E4%B8%AD%E6%89%BE%E5%88%B0%E8%BD%AF%E4%BB%B6%E5%8C%85%20libc6-dbg%3Ai386.png)
我正在尝试在基于 Ubuntu 的 docker 容器内安装 libc6-dbg:i386 因为 Valgrind 需要它,但我做不到。
给定以下 Dockerfile:
FROM ubuntu:14.04
MAINTAINER Me <[email protected]>
RUN apt-get update
RUN apt-get install libc6-dbg
RUN apt-get install libc6-dbg:i386
在 Ubuntu 14.04 桌面 64 位主机上运行:
sudo docker build .
我得到:
Step 0 : FROM ubuntu:14.04
---> 5506de2b643b
Step 1 : MAINTAINER Me <[email protected]>
---> Using cache
---> b1792911b80d
Step 2 : RUN apt-get update
---> Using cache
---> 5e3928c88aff
Step 3 : RUN apt-get install libc6-dbg
---> Running in ebd51fcb278b
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
libc6-dbg
0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded.
Need to get 3452 kB of archives.
After this operation, 22.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libc6-dbg amd64 2.19-0ubuntu6.3 [3452 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
Fetched 3452 kB in 0s (5325 kB/s)
Selecting previously unselected package libc6-dbg:amd64.
(Reading database ... 11527 files and directories currently installed.)
Preparing to unpack .../libc6-dbg_2.19-0ubuntu6.3_amd64.deb ...
Unpacking libc6-dbg:amd64 (2.19-0ubuntu6.3) ...
Setting up libc6-dbg:amd64 (2.19-0ubuntu6.3) ...
---> fe4bf0f008db
Removing intermediate container ebd51fcb278b
Step 4 : RUN apt-get install libc6-dbg:i386
---> Running in 460cab3c4631
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libc6-dbg
2014/11/20 15:23:06 The command [/bin/sh -c apt-get install libc6-dbg:i386] returned a non-zero code: 100
在主机上我可以安装libc6-dbg:i386,为什么我不能将它安装在docker容器内?
答案1
我会亲自回答这个问题。
解决此问题所需的信息位于https://wiki.debian.org/Multiarch/HOWTO。
官方 docker ubuntu 镜像和 phusion/baseimage 中的 Apt 仅配置了对 amd64 的支持。如果你问,它会告诉你:
# dpkg --print-architecture
amd64
# dpkg --print-foreign-architectures
<no output>
解决这个问题的方法是在apt-get 更新:
# dpkg --add-architecture i386
# apt-get update
<lots of lines>
# apt-get install libc6-dbg:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
gcc-4.9-base:i386 libc6:i386 libgcc1:i386
Suggested packages:
glibc-doc:i386 locales:i386
The following NEW packages will be installed:
gcc-4.9-base:i386 libc6:i386 libc6-dbg:i386 libgcc1:i386
0 upgraded, 4 newly installed, 0 to remove and 21 not upgraded.
Need to get 7039 kB of archives.
After this operation, 26.4 MB of additional disk space will be used.
Do you want to continue? [Y/n]
为了完整起见,以下是最终的 Dockerfile:
FROM ubuntu:14.04
MAINTAINER Me <[email protected]>
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install libc6-dbg
RUN apt-get install libc6-dbg:i386
答案2
apt-get update
尝试在 Dockerfile 中添加以下行:
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list