Docker on Raspian

!
Warning: This post is over 365 days old. The information may be out of date.

You have one or more spare Raspberry Pi and you want to try docker on it ? Let’s go !

Install Raspian

For this part, you can follow my previous post : Raspian installation

Install Docker

  • The Docker way

    As mentionned in the documentation ( Docker installation ), the preferred way to install Docker on ARM is to use the convenience script.

    $ curl -fsSL get.docker.com | sudo bash
    

    From a personnal point of vue, i don’t like these kind of setups (i like to know what happens on my systems).

  • The other way

    • Install dependancies :

      $ sudo apt-get install apt-transport-https
      
    • Create /etc/apt/sources.list.d/docker.list

      $ sudo echo "deb [arch=armhf] https://download.docker.com/linux/raspbian $(lsb_release -c -s) stable" > /etc/apt/sources.list.d/docker.list
      

    If you want to test the latest version of Docker, change stable by edge

    • Get the apt key :

      $ wget -O - https://download.docker.com/linux/raspbian/gpg | sudo apt-key add -
      
    • Install Docker :

      $ sudo apt-get update && sudo apt-get install docker-ce
      
    • Optionnal : allow some users to use Docker (for example, user pea) :

      $ sudo usermod -G docker pea
      

And now ?

Now you have Docker installed and running :

$ docker version
Client:
 Version:	17.12.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	c97c6d6
 Built:	Wed Dec 27 20:21:15 2017
 OS/Arch:	linux/arm

Server:
 Engine:
  Version:	17.12.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	c97c6d6
  Built:	Wed Dec 27 20:17:21 2017
  OS/Arch:	linux/arm
  Experimental:	false

Remove some warnings

If you run docker info, you will see some warnings at the end of the display:

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.12.0-ce
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 macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.14.10-v7+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 927.2MiB
Name: docker04
ID: NK44:JM7Z:FRK7:NBS3:EM2U:BZ4P:YVJG:DFG3:M3PJ:2QYK:TD2M:X3QV
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

We can get rid of some of these warnings.

Modify the /boot/cmdline.txt, add these two parameters : cgroup_enable=memory swapaccount=1 and reboot

$ cat /boot/cmdline.txt 
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=d5e34328-02 rootfstype=ext4 elevator=deadline fsck.repair=yes cgroup_enable=memory swapaccount=1 rootwait

Now, we have:

$ docker info
...
WARNING: No swap limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

cfs is not compiled for the Raspian Kernel, so you will keep these warnings.

Customize your Docker daemon

If you want to add some options to your dockerd daemon, you will have to follow these steps :

  • Create the /etc/systemd/system/docker.service.d/ directory :

    $ sudo mkdir /etc/systemd/system/docker.service.d/
    
  • Create the options.conf file with all your options, for example :

    $ sudo cat /etc/systemd/system/docker.service.d/options.conf
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd -H fd:// --bip 172.20.0.1/24 --dns 192.168.1.1 --dns ::1 --ipv6 --fixed-cidr-v6="xxx:xxx:xxx:xxx::/64"
    
  • Restart docker

Enjoy your new Docker machine 😄

Related Posts