apt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': 设备或资源忙
Posted
技术标签:
【中文标题】apt-get install in Ubuntu 16.04 docker image: \'/etc/resolv.conf\': 设备或资源忙【英文标题】:apt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': Device or resource busyapt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': 设备或资源忙 【发布时间】:2016-11-29 23:24:48 【问题描述】:从一个相当普通的 Ubuntu 16.04 映像中运行 apt-get install 时,我收到以下错误消息:
ln: cannot remove '/etc/resolv.conf': Device or resource busy
dpkg: error processing package resolvconf (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
resolvconf
不过,这些软件包似乎安装正确。如何解决?
我的 Dockerfile 看起来像这样:
FROM ubuntu:16.04
MAINTAINER Me Myself <me@myself.com>
RUN apt-get update && apt-get install -y git nano
RUN apt-get upgrade -y
# set the timezone. Note: there is an Ubuntu 16.04 bug which
# requires this to be done this way:
# http://***.com/questions/40234847/docker-timezone-in-ubuntu-16-04-image/40235306#40235306
RUN ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN locale-gen en_US en_US.UTF-8 de_DE.UTF-8
ENV PATH="/opt/xyz/bin:$PATH"
【问题讨论】:
检查这个 Docker 错误条目:github.com/docker/docker/issues/1297 【参考方案1】:如https://github.com/moby/moby/issues/1297 中所述,您可以将以下行添加到您的Dockerfile
:
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
这样可以在容器中安装resolvconf
。
【讨论】:
【参考方案2】:@Christian Berendt 的上述评论和回答,我仍然得到这些错误:
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:
这是我的完整解决方案,将这些行添加到 Dockerfile 中:
这些行有助于安装 resolvconf 和 debconf 错误
RUN apt-get update
RUN apt-get install -y apt-utils debconf-utils dialog
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
RUN apt-get update
RUN apt-get install -y resolvconf
【讨论】:
您应该将所有这些都放在一个 RUN 命令中,以避免在构建此图像的每个步骤中创建一个层 更好的是简单地包含以下行,禁用交互模式而不安装新包:ENV DEBIAN_FRONTEND noninteractive
以上是关于apt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': 设备或资源忙的主要内容,如果未能解决你的问题,请参考以下文章
Ubuntu下apt-get安装文件提示:apt-get -f install
Ubuntu apt-get: Package has no installation candidate
如何解决ubuntu下apt-get install g++依赖问题
ubuntu MySQL采用apt-get install安装目录