Paraphraser / PiBuilder

Ideas for building a Raspberry Pi from "bare metal" to ready-to-run IOTstack
MIT License
110 stars 24 forks source link

Script 04_setup.sh : "Could not resolve host: download.docker.com" #2

Closed Noschvie closed 2 years ago

Noschvie commented 2 years ago

Hi Phill

running script 04_setup.sh leads to "Could not resolve host: download.docker.com". In this case I suggest to skip the installation of docker-compose and terminate the script with a warning. I have overlooked the error message and during .\menu.sh docker was missing

What do you mean? thanks, Norbert

pi@erdberg:~ $ /boot/scripts/04_setup.sh false
Importing user options from /boot/scripts/support/pibuilder/options.sh
Installing docker
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sh -c apt-get update -qq >/dev/null
+ sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
curl: (6) Could not resolve host: download.docker.com
gpg: no valid OpenPGP data found.
Setting groups required for docker and bluetooth
usermod: group 'docker' does not exist
Installing docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   663  100   663    0     0   2393      0 --:--:-- --:--:-- --:--:--  2393
100 21.7M  100 21.7M    0     0  3801k      0  0:00:05  0:00:05 --:--:-- 5052k
Modern docker-compose installed as /home/pi/.docker/cli-plugins/docker-compose - also copied to /usr/local/bin/
Installing IOTstack dependencies
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting ruamel.yaml==0.16.12
  Downloading https://www.piwheels.org/simple/ruamel-yaml/ruamel.yaml-0.16.12-py2.py3-none-any.whl (111 kB)
     |████████████████████████████████| 111 kB 187 kB/s
Collecting blessed
  Downloading https://www.piwheels.org/simple/blessed/blessed-1.19.1-py2.py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 271 kB/s
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from blessed) (1.16.0)
Collecting wcwidth>=0.1.4
  Downloading https://www.piwheels.org/simple/wcwidth/wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Installing collected packages: wcwidth, ruamel.yaml, blessed
Successfully installed blessed-1.19.1 ruamel.yaml-0.16.12 wcwidth-0.2.5
Appending cgroup_memory=1 cgroup_enable=memory to /boot/cmdline.txt
04_setup.sh complete - rebooting...
Paraphraser commented 2 years ago

Hi Norbert,

Thanks for opening this issue.

On the face of it, this is a transient problem that is one step removed from PiBuilder.

If you drill down into the 04 script, most of the complexity is for Supervised Home Assistant. If Home Assistant is not being installed then it boils down to:

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -G docker -a $USER
sudo usermod -G bluetooth -a $USER

and then there's a bit more complexity for getting modern docker-compose installed.

In your output, the "Could not resolve host: download.docker.com" error message is coming from the sudo sh which is running the "get.docker.com" script just downloaded by curl. That error terminates the "get.docker.com" script before it adds the "docker" group to /etc/groups, so the first usermod then fails too.

If you think about it, the very fact that the script was able to start running proves:

  1. That your DNS is working - curl was able to resolve the name "get.docker.com"; and
  2. That you have Internet connectivity - curl was able to download the script from "get.docker.com" in order to pipe it to sudo sh.

That's what suggests to me that the "get.docker.com" script's inability to resolve "download.docker.com" is probably transient.

The host "download.docker.com" is resolvable from my system:

$ date ; dig download.docker.com +short
Sat Mar 12 09:52:06 AEDT 2022
d2h67oheeuigaw.cloudfront.net.
99.86.143.82
99.86.143.16
99.86.143.116
99.86.143.107

If you run the same dig command and get a bunch of IP addresses (not necessarily the same ones) then it is probably safe to conclude "transient". If, however, your system is still unable to resolve "download.docker.com" then it would suggest a more persistent problem which has something to do with your DNS arrangements. That's something you would need to figure out (I could give you a few tips so please don't be afraid of asking).

Having said all that, I take your point about how the 04 script should be better behaved. I'll start checking the "get.docker.com" script's exit code and bung out an "unable to proceed" message.


If the dig download.docker.com test succeeds at your end and you want to try repairing your system, you should be able to just run:

$ curl -fsSL https://get.docker.com | sudo sh
$ sudo usermod -G docker -a $USER
$ sudo usermod -G bluetooth -a $USER
$ sudo reboot

You could also read through Reinstalling docker + docker-compose. That guide is intended for situations where components are half-installed. What it tells you to do is more "brute force" but it will get the job done.

Noschvie commented 2 years ago

Hi Phill thanks for your explanation. Did an installation from scratch and now it's ok

 $ date ; dig download.docker.com +short
Sun 13 Mar 18:17:11 CET 2022
d2h67oheeuigaw.cloudfront.net.
13.32.121.111
13.32.121.35
13.32.121.78
13.32.121.29
Paraphraser commented 2 years ago

Code added to 04 script to check exit code from docker install script, display some (hopefully) helpful text, and exit the 04 script at that point. That should mean that, if there's a transient like you experienced, it would be safe to just wait a while then rerun 04.