dig +short prints its own errors (";; no servers could be reached") on
stdout, and the check counted any line that was not 127.x or 0.0.0.0 as
an address, so with a dead resolver the fallback to 1.1.1.1 never ran
and the install failed further on. Count only address lines.
The original resolv.conf was put back only after a successful install;
any failure left the container on 1.1.1.1, and a second run then saved
that as the backup. Restore it on exit.