24

How would I go about running Docker (https://www.docker.io) on Raspbian?

The instructions I've found are either a very manual process based on Raspbian but with a very old kernel that seemed to require a bunch of patches. There's also the well-known build by the resin.io folks, but it's specifically made for Arch Linux.

Current Raspbian kernel is 3.10.25 which is modern enough to have most of the stuff that Docker needs. I'm not above building a new kernel, but is that still necessary?

Has anyone figured out how to get Docker and its requirements going on the Pi?

goldilocks
  • 58,859
  • 17
  • 112
  • 227
Martijn Heemels
  • 428
  • 1
  • 4
  • 7
  • Interesting question. I'll also be interested in an answer to this. Have you tried those instructions at all? – Jivings Apr 24 '14 at 18:46
  • 1
    No, I've read all I could find. I'm specifically looking to use Raspbian so the Arch instructions weren't very useful. The Raspbian instructions by Ken Cochrane seem very old, requiring many steps to even get Raspbian up-to-date, let alone Docker, and don't even result in a working setup. I was hoping to gather some info before spending a ton of time on it. – Martijn Heemels Apr 26 '14 at 22:12
  • 1
    One this I've realized is that Docker containers aren't really cross-architecture. Since the containers share the kernel with the host-OS, the applications inside the containers are bound to the armv6 architecture. You can't build a docker image on x86 and run it on armv6, which puts limitation on your build system. There's a base-image available here: https://index.docker.io/u/resin/rpi-raspbian/ – Martijn Heemels Apr 26 '14 at 22:19
  • So it's possible but not to do what you want? – Jivings Apr 27 '14 at 17:21
  • Yes, it seems possible but not as useful as I hoped. Still, it may be useful for others, so up-to-date installation instructions would be valuable. – Martijn Heemels Apr 28 '14 at 10:19
  • 1
    Well it looks like their claim self-sufficient container that will run virtually anywhere is falling short. It sounds like for it to run on something, docker needs to be compatible with the device its running on. It sounds like Mono or Java which are more promising, but not really what you need. Why do you need this on the Pi any way? If you developing for Linux, you should really develop in what it supports natively. – Piotr Kula Apr 28 '14 at 19:14
  • Yeah, every 'runs-everywhere' system seems to have some limitations. Of course, the low overhead of Linux containers have to come from somewhere. I intended to run Docker on a Pi that is going to be colocated in a remote datacenter. It would run mostly web applications and e-mail. This could of course easily be run straight on the Pi, but it would've been nice to keep the base OS clean and abstract the host away, as well as providing a nice packaging and distribution method. Docker seems useful for that. – Martijn Heemels Jun 12 '14 at 07:36
  • I recently had a problem with apt-get install docker.io installing a quite old version of docker on a raspbian-jessy. Solved it using the repo from this guys: https://blog.hypriot.com/post/your-number-one-source-for-docker-on-arm/

    (comment posted to this question, since it's pretty high on google search results for "latest docker on raspbian")

    – Ufos Jul 14 '17 at 09:41

5 Answers5

14

Yes, I have built a kernel and ported Docker 1.0 to the Raspbian OS: Linux raspberrypi 3.10.37+ #1 PREEMPT Sat Apr 19 13:28:05 UTC 2014 armv6l GNU/Linux

I have shared my outputs on GitHub to save others the pain. As is usual I have provided this 'as-is' with no warranty ;-)

You can find the kernel & docker tar file here:

https://github.com/stevef1uk/docker_for_rpi

Seahope
  • 156
  • 1
  • 3
  • 1
    That's very interesting. Thanks for sharing. Would you mind adding the steps for compiling the kernel? Particularly, which options did you change in the config? I'm about to try building my own kernel via the steps listed on http://elinux.org/RPi_Kernel_Compilation. – Martijn Heemels Jun 12 '14 at 08:11
  • 3
    Actually, I have already done that as well as how to cross compile. You can find my blogs here: http://stevef1uk.blogspot.com/2014/06/here-be-dragons-how-to-cross-compile.html & http://stevef1uk.blogspot.com/2014/06/how-to-run-docker-on-raspberry-pi.html – Seahope Jun 13 '14 at 20:51
7

You can also use HypriotOS, which provides the latest Docker and Linux kernel for Raspberry Pi. Just flash the image and see Docker up and running!

http://blog.hypriot.com/

(disclosure: I am a team member of Hypriot)

  • Thanks, using your new image on my new Pi2. Works great! I've tried it with a variety of armhf images from Docker Hub. – Martijn Heemels Mar 04 '15 at 21:28
  • 1
    @MathiasRenner is there a reason hypriot is not open source? Are you planning to monetize on the image? – jottr Jul 21 '15 at 22:00
  • 1
    @jottr Thank you for your interest! Actually, everything from Hypriot you need to run Docker on RPI is open sourced. You need (1) a proper kernel (github.com/hypriot/rpi-kernel-builder) and (2) the Docker binary (github.com/hypriot/rpi-docker-builder). Just build and install both and you are ready to go! – Mathias Renner Jul 23 '15 at 14:14
  • @MathiasRenner ah great! Thx for the pointers. – jottr Jul 24 '15 at 15:14
  • This also works nicely on Raspbian Jessie; http://blog.hypriot.com/post/your-number-one-source-for-docker-on-arm/ – Arjan May 01 '16 at 13:21
3

If you use Raspbian:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install docker.io docker

Docker is now in the default repository,

Update: unfortunately this version is quite old, so pulling in images from Docker Hub won't work at the moment.

Janghou
  • 1,446
  • 1
  • 16
  • 20
  • The version in the default repo is super old, 1.3.3 as of this comment. It no longer works with the docker registry making it mostly useless. – DriverDan Mar 27 '16 at 19:06
  • Agreed. Hopefully the package in Raspbian will be updated soon, maybe a bug/feature request will help – Janghou Mar 31 '16 at 09:52
  • There's 1.8.3 (October 2015) in the Raspbian testing repository. – nphx Apr 03 '16 at 06:57
  • See http://blog.hypriot.com/post/your-number-one-source-for-docker-on-arm/ for Docker 1.10 on Raspbian Jessie. – Arjan May 01 '16 at 13:20
3

Docker supports ARMv6/v7 and even ARM64 (v8?), so you can run it on your Raspberry Pis.

Follow the official instructions from Docker here: https://docs.docker.com/engine/installation/linux/docker-ce/debian/

If you have Raspbian Jessie or Stretch (check the above documentation for others), this would be:

$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
$ echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
     $(lsb_release -cs) stable" | \
     sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt-get update; sudo apt-get install docker-ce
$ sudo systemctl start docker

You can then test it (thanks to Docker multiarch support):

$ sudo docker run --rm hello-world

In order to avoid typing sudo for every Docker invocation, you can do the following extra steps: https://docs.docker.com/engine/installation/linux/linux-postinstall/

Enjoy!

PS: I've installed Ubuntu Server 16.04 for armhf. I have then followed these instructions (for Ubuntu) to install Docker on it: https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#set-up-the-repository. It works like a charm as well.

Huygens
  • 733
  • 5
  • 12
2

I have always used...

curl -sSL https://get.docker.com | sh && sudo usermod -aG docker pi

However, I just saw a deprecation notice this morning...

WARNING: raspbian is no longer updated @ https://get.docker.com/
         Installing the legacy docker-engine package...
Zak
  • 141
  • 5
  • I just noticed this too - do you know what it means? What are the implications of this? – davidA Aug 18 '17 at 04:20
  • It means it works today, but it probably won't work tomorrow. It also means you should write to the moby project (i.e. the folks that maintain docker), tell them how awesome it is and beg them to please keep maintaining it. :D – Zak Aug 18 '17 at 06:31
  • Do you know if there's an alternative? Presumably I could always fall back to the manual installation process on Raspbian? – davidA Aug 18 '17 at 22:26
  • No, I don't know. However, the Moby Project should be able to answer that question. – Zak Aug 18 '17 at 23:44
  • Thanks, I'm reaching out. I'd hate to see Docker disappear from raspbian - running microservices via Docker on a RPi is amazing... – davidA Aug 20 '17 at 00:58
  • Docker for Raspbian is not deprecated. You can install the latest version from Docker on it, check the installation manual from Docker how to do it: https://docs.docker.com/engine/installation/linux/docker-ce/debian/ – Huygens Nov 15 '17 at 09:47