Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device or resource busy - Docker

When doing apt-get -y upgrade on a new Ubuntu 14.04 machine with the ubuntu:latest (Xenial) image, it raised an error:

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

I've a fresh install of docker on a fresh Ubuntu 14.04, using these command:

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

Docker for hello-world runs fine:

$ 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/

When I create an empty docker container with:

docker run -it ubuntu bash

and ran the following:

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

The error:

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

is raised when doing the last apt-get -y upgrade

The full docker log is on: https://gist.github.com/alvations/ebe7175b984213d6f64a3c779ba3249e

like image 511
alvas Avatar asked Apr 07 '17 04:04

alvas


People also ask

How much RAM should I allocate to Docker?

Limit a container's access to memory The maximum amount of memory the container can use. If you set this option, the minimum allowed value is 6m (6 megabytes). That is, you must set the value to at least 6 megabytes. The amount of memory this container is allowed to swap to disk.

Can Docker run on 2gb RAM?

you can run 20+ WordPress site with 2gb ram vps. my server using only used 48% ram. latest ubuntu server take 20-30%+ ram for running. a medium size container can take 2–3% of ram.

Why is Docker running so slow?

When you experience slow Docker performance, check your CPU, memory usage, and available disk space. Consider upgrading your system if a component does not perform as expected. When dealing with a specific container that is performing worse than expected, it may be helpful to check container-specific metrics.

Does Docker use all CPU cores?

If no value is provided docker will use a default value. On windows, a container defaults to using two CPUs. If hyperthreading is available this is one core and two logical processors. If hyperthreading is not available this is two cores and two logical processors.


Video Answer


2 Answers

Agree with other answers/comments that apt-get -y upgrade isn't as good an idea as pulling a newer/updated image. Where a particular package is required but out of date in an image, installing that particular package is often enough (since dependencies will be updated as necessary).

However, there really is no reason that you shouldnt be able to use apt-get -y upgrade and in fact, I'd consider this a bug, similar to but not exactly the same as:

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

The part that is failing is the first call to MAKEDEV in the postinst script but this is handled and the script continues. Ultimately this means there is no current issue with installing makedev. But this may not always be true so probably requires a bug to be raised with Ubuntu to have docker containers detected as well (somehow).

Note: if you care about makedev ruining your docker /dev/ directory currently or want to make sure you get rid of any error condition from installing makedev, the fix for the bug I linked to can be used to trick the postinstall script into not running. The check in the script says:

# 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

so if you were to add an environment variable whose name ends in container with the value lxc, then the check would be tripped and no new devices would be installed

docker run -ti -e "ImNotAnLXCcontainer=lxc" ubuntu

This will cause the script to exit, not create a whole bunch of /dev/ entries, and output the message:

Setting up makedev (2.3.1-93ubuntu2~ubuntu16.04.1) ...
LXC container detected, aborting due to LXC managed /dev.
like image 109
spacepickle Avatar answered Nov 07 '22 22:11

spacepickle


Docker containers aren't full VMs. They share the kernel with the host, so it's not surprising that some low-level operations, such as making devices, will fail. However, I do note that the command doesn't fail despite the error message - the command returns 0. I would suggest that the container actually works as expected.

Despite this, the best answer is simply not to run apt-get upgrade. You're using the ubuntu:latest image, which is kept up-to-date by Docker with new versions. So, rather than do apt-get upgrade to get a new version, just do docker pull ubuntu:latest.

You can check when the latest image was last updated here https://github.com/docker-library/repo-info/blob/master/repos/ubuntu/remote/latest.md. At the time of writing, the last update was over 6 weeks ago, so it will be missing some updates. Whilst I'm disappointed that it's not more up-to-date, I would still recommend against running upgrade as you are likely to have problems and are moving the responsibility for updates onto yourself. Please open an issue if there is an important update that is missing.

I do note that the debian image seems to be kept more up-to-date, probably because it is used as a base image for many of the official images - I would recommend using this if possible.

like image 30
Adrian Mouat Avatar answered Nov 07 '22 22:11

Adrian Mouat