TLDR
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Important note
- Use a power supply that has enough power. The Rasperry Pi might not work correctly when it has not enough power.
Installation
First download from get.docker.com the installation script using curl. Save the script in the file ‘get-docker.sh
‘. Check the script and compare it with the original version on github. Then run the script with ‘sh
‘.
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
The above codes can be joined into a single line. The script is then run immediately after downloading, it cannot be checked. Unfortunately, the ‘&&
‘ are not rendered correctly with the SyntaxHighlighter:
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Even shorter, without writing the script file ‘get-docker.sh
‘ to the current directory. I would not recommend this version though.
curl -sSL https://get.docker.com/ | sh
Problems
When installing Docker I somehow encountered problems and the connection to the Raspberry Pi froze. Looking at the Docker info I saw that the server was not running:
pi@raspberrypi:~ $ sudo docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
After some research I tried to reinstall the docker-engine:
sudo apt-get install -y -q docker-engine
… but received again an error:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
… so I typed in the suggested command:
As far as I remember, this command used to freeze previously. After some research I decided to use a more powerfull power supply for the Raspberry Pi. This time, it was installing correctly:
pi@raspberrypi:~ $ sudo dpkg --configure -a
Setting up containerd.io (1.2.10-3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-ce-cli (5:19.03.5~3-0~raspbian-buster) ...
Setting up docker-ce (5:19.03.5~3-0~raspbian-buster) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u1+rpi1) ...
Check the installation
I checked the installation with docker info. It seems to be alright now:
pi@raspberrypi:~ $ sudo docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.5
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.19.75-v7+
Operating System: Raspbian GNU/Linux 10 (buster)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 926.1MiB
Name: raspberrypi
ID: VMGN:PNRJ:3O7Q:PXSZ:HKHG:EF7R:6LAD:FAIJ:SJMS:GRMU:EF5P:6HNL
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
Hello world
Now it’s time to run the hello world:
pi@raspberrypi:~ $ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018fbf5
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.
(arm32v7)
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://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
References
Appendix: Curl options
See: https://manpages.debian.org/buster/curl/curl.1.en.html
-f, –fail
(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with failed attempts. In normal cases when an HTTP server fails to deliver a document, it returns an HTML document stating so (which often also describes why and more). This flag will prevent curl from outputting that and return error 22.
This method is not fail-safe and there are occasions where non-successful response codes will slip through, especially when authentication is involved (response codes 401 and 407).
-s, –silent
Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
See also -v, –verbose and –stderr.
-S, –show-error
When used with -s, –silent, it makes curl show an error message if it fails.
-L, –location
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, –include or -I, –head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won’t be able to intercept the user+password. See also –location-trusted on how to change this. You can limit the amount of redirects to follow by using the –max-redirs option.
When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.
You can tell curl to not change the non-GET request method to GET after a 30x response by using the dedicated options for that: –post301, –post302 and –post303.
-o, –output <file>
Write output to <file> instead of stdout. If you are using {} or [] to fetch multiple documents, you can use ‘#’ followed by a number in the <file> specifier. That variable will be replaced with the current string for the URL being fetched. Like in:
curl http://{one,two}.example.com -o “file_#1.txt”
or use several variables like:
curl http://{site,host}.host[1-5].com -o “#1_#2”
You may use this option as many times as the number of URLs you have. For example, if you specify two URLs on the same command line, you can use it like this:
curl -o aa example.com -o bb example.net
and the order of the -o options and the URLs doesn’t matter, just that the first -o is for the first URL and so on, so the above command line can also be written as
curl example.com example.net -o aa -o bb
See also the –create-dirs option to create the local directories dynamically. Specifying the output as ‘-‘ (a single dash) will force the output to be done to stdout.
See also -O, –remote-name and –remote-name-all and -J, –remote-header-name.