设备或资源繁忙 - Docker

alv*_*vas 7 ubuntu package-managers device apt-get docker

apt-get -y upgrade使用ubuntu:latest(Xenial)映像的新Ubuntu 14.04计算机上执行时,它引发了一个错误:

Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ...
mv: cannot move 'console-' to 'console': Device or resource busy
makedev console c 5 1 root tty 0600: failed
Run Code Online (Sandbox Code Playgroud)

我在新的Ubuntu 14.04上安装了一个全新的docker,使用以下命令:

sudo apt-get remove docker docker-engine
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
wget -qO- https://get.docker.com/ | sudo sh
su - $USER # To logout and login
Run Code Online (Sandbox Code Playgroud)

Docker hello-world运行正常:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete 
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
Run Code Online (Sandbox Code Playgroud)

当我创建一个空的docker容器时:

docker run -it ubuntu bash
Run Code Online (Sandbox Code Playgroud)

并执行以下操作:

apt-get update
apt-get install -y debconf-utils
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
apt-get update
apt-get -y upgrade
Run Code Online (Sandbox Code Playgroud)

错误:

Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ...
mv: cannot move 'console-' to 'console': Device or resource busy
makedev console c 5 1 root tty 0600: failed
Run Code Online (Sandbox Code Playgroud)

在做最后一次时被提出 apt-get -y upgrade

完整的泊坞日志开启:https://gist.github.com/alvations/ebe7175b984213d6f64a3c779ba3249e

spa*_*kle 4

同意其他答案/评论,这些答案/评论apt-get -y upgrade并不像提取更新/更新的图像那么好。如果需要特定的包但在映像中已过时,安装该特定的包通常就足够了(因为依赖项将根据需要进行更新)。

然而,确实没有理由你不应该使用apt-get -y upgrade,事实上,我认为这是一个错误,类似于但不完全相同:

https://bugs.launchpad.net/ubuntu/+source/makedev/+bug/1675163

失败的部分是 postinst 脚本中对 MAKEDEV 的第一次调用,但这已处理并且脚本继续。最终这意味着安装 makedev 目前不存在问题。但这可能并不总是正确的,因此可能需要在 Ubuntu 中提出一个错误才能检测到 docker 容器(以某种方式)。

笔记:如果您当前关心 makedev 破坏您的 docker /dev/ 目录,或者想要确保摆脱安装 makedev 时出现的任何错误情况,我链接到的错误修复可用于欺骗安装后脚本不运行。脚本中的检查显示:

# don't stomp on LXC users
if grep -q container=lxc /proc/1/environ
then
    echo "LXC container detected, aborting due to LXC managed /dev."
    exit 0
fi
Run Code Online (Sandbox Code Playgroud)

因此,如果您要添加名称以值为 lxc 的容器结尾的环境变量,则检查将被触发,并且不会安装新设备

docker run -ti -e "ImNotAnLXCcontainer=lxc" ubuntu
Run Code Online (Sandbox Code Playgroud)

这将导致脚本退出,而不是创建一大堆 /dev/ 条目,并输出消息:

Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ...
LXC container detected, aborting due to LXC managed /dev.
Run Code Online (Sandbox Code Playgroud)