apt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': Device or resource busy

非 Y 不嫁゛ 提交于 2021-01-02 06:50:57

问题


I'm getting the error message below when running apt-get install from within a rather vanilla Ubuntu 16.04 image:

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

The packages seem to be installed correctly, though. How to fix it?

My Dockerfile looks like this:

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://stackoverflow.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}"

回答1:


As mentioned in https://github.com/moby/moby/issues/1297 you can add RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections to your Dockerfile. This way it is possible to install resolvconf inside a container.




回答2:


With the above comment and answer of @Christian Berendt, I still get these errors:

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: 

Here is my complete solution, by adding these lines into the Dockerfile:

These lines help install resolvconf withode debconf errors

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


来源:https://stackoverflow.com/questions/40877643/apt-get-install-in-ubuntu-16-04-docker-image-etc-resolv-conf-device-or-reso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!