I’ve spent a lot of time in *nix-like environments, but Docker + Linux configuration nuances a bit of a newer area to me. This is my public personal note about how to do deal with an EBUSY on /etc/resolv.conf in a Linux Docker container (as well as similarly mounted files in containers)
In debugging an issue with a build in which a kitchen test was failing to update /etc/resolv.conf
with an EBUSY
from within a Linux Docker container, I stumbled upon “Device or resource busy” when i try move /etc/resolv.conf in ubuntu:18.04. How fix it?
Within the Docker container the
https://stackoverflow.com/a/60576223/725805/etc/resolv.conf
file is not an ordinary regular file. Docker manages it in a special manner: the container engine writes container-specific configuration into the file outside of the container and bind-mounts it to/etc/resolv.conf
inside the container.
So, the resolution is to write to the file, rather than move a new version of the file to /etc/resolv.conf
:
root@824caa8d90e1:/# echo 'nameserver 8.8.8.8' > /etc/resolv.conf root@824caa8d90e1:/# root@824caa8d90e1:/# root@824caa8d90e1:/# echo 'nameserver 1.1.1.1' > /etc/resolv2.conf root@824caa8d90e1:/# mv /etc/resolv2.conf /etc/resolv.conf mv: cannot move '/etc/resolv2.conf' to '/etc/resolv.conf': Device or resource busy
Chef anticipates this in the file resource but something about the environment setup is overriding it.