Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bullshit/10502689 to your computer and use it in GitHub Desktop.
Save bullshit/10502689 to your computer and use it in GitHub Desktop.
Install Docker on Raspberry Pi (Arch Linux)

Install Docker on Raspberry Pi (Arch Linux)

Prepare SD Card

  1. Download Image
  2. Unzip Image
  3. Copy Image on SD Card (dd if=./ArchLinuxARM-2014.03-rpi.img of=/dev/disk2)
  4. Boot Raspberry Pi

Connect to Pi

  1. Find out IP

  2. ssh [email protected]

    Password is root

Resize SD Card

[root@alarmpi ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.7G  415M  1.1G  27% /
devtmpfs         84M     0   84M   0% /dev
tmpfs           232M     0  232M   0% /dev/shm
tmpfs           232M  288K  231M   1% /run
tmpfs           232M     0  232M   0% /sys/fs/cgroup
tmpfs           232M     0  232M   0% /tmp
/dev/mmcblk0p1   90M   25M   66M  28% /boot
  1. Open fdisk

    [root@alarmpi ~]# fdisk /dev/mmcblk0

    Welcome to fdisk (util-linux 2.24.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): 
    
  2. Press ‘p’ to print the partition table:

    Welcome to fdisk (util-linux 2.24.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    Disk /dev/mmcblk0: 14.7 GiB, 15811477504 bytes, 30881792 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x417ee54b
    
    Device         Boot     Start       End  Blocks  Id System
    /dev/mmcblk0p1           2048    186367   92160   c W95 FAT32 (LBA)
    /dev/mmcblk0p2         186368   3667967 1740800   5 Extended
    /dev/mmcblk0p5         188416   3667967 1739776  83 Linux
    
  3. Press 'd' to delete a partition:

    1. Enter '2' to choose the second partition.
    Command (m for help): d
    Partition number (1,2,5, default 5): 2
    
    Partition 2 has been deleted.
    
  4. Press 'n' to create a new partition:

    1. Enter 'e' to select extended as partition type.
    2. Partition number: to accept 2 as default partition number.
    3. First sector: to accept default.
    4. Last sector: to accept default.
    Command (m for help): n
    
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): e
    Partition number (2-4, default 2): 2
    First sector (186368-30881791, default 186368):
    Last sector, +sectors or +size{K,M,G,T,P} (186368-30881791, default 30881791):
    
    Created a new partition 2 of type 'Extended' and of size 14.7 GiB.
    
  5. Press 'n' to create a new partition:

    1. Enter 'l' to select logical as partition type.
    2. First sector: to accept default.
    3. Last sector: to accept default.
    Command (m for help): n
    
    Partition type:
       p   primary (1 primary, 1 extended, 2 free)
       l   logical (numbered from 5)
    Select (default p): l
    
    Adding logical partition 5
    First sector (188416-30881791, default 188416):
    Last sector, +sectors or +size{K,M,G,T,P} (188416-30881791, default 30881791):
    
    Created a new partition 5 of type 'Linux' and of size 14.7 GiB.
    
  6. Press 'w' to write the new partition table.

    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Re-reading the partition table failed.: Device or resource busy
    
    The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
    [root@alarmpi ~]# 
    
  7. Reboot to force the kernel to recognize the new parition table

    [root@alarmpi ~]# reboot

  8. Reconnect to raspberry

    ssh [email protected]

  9. Execute following command

    [root@alarmpi ~]# resize2fs /dev/mmcblk0p5

    resize2fs 1.42.9 (28-Dec-2013)
    Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
    old_desc_blocks = 1, new_desc_blocks = 1
    The filesystem on /dev/mmcblk0p5 is now 3836672 blocks long.
    
  10. Control if everythink worked

    [root@alarmpi ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root        15G  416M   14G   3% /
    devtmpfs         84M     0   84M   0% /dev
    tmpfs           232M     0  232M   0% /dev/shm
    tmpfs           232M  288K  231M   1% /run
    tmpfs           232M     0  232M   0% /sys/fs/cgroup
    tmpfs           232M     0  232M   0% /tmp
    /dev/mmcblk0p1   90M   25M   66M  28% /boot
    

Setup timezone

  1. Find out the current configured timezone

    [root@alarmpi ~]# timedatectl status

  2. List avaiable timezones

    [root@alarmpi ~]# timedatectl list-timezones

  3. Set your timezone (for example Europe/Berlin)

    [root@alarmpi ~]# timedatectl set-timezone Europe/Berlin

Change hostname

  1. Set the hostname to your liking (e.g. arch):

    [root@alarmpi ~]# hostnamectl set-hostname arch

  2. Add the same hostname to /etc/hosts:

    [root@alarmpi ~]# nano /etc/hosts

    #
    # /etc/hosts: static lookup table for host names
    #
    
    #<ip-address>   <hostname.domain.org>   <hostname>
    127.0.0.1       localhost.localdomain   localhost arch
    ::1             localhost.localdomain   localhost arch
    
    # End of file
    
    1. After you add your hostname press "crtl+x", "y" and hit "enter" to exit nano and save your changes

Install Software

  1. Docker with the needed kernel extensions

    [root@alarmpi ~]# wget -O - https://raw.github.com/resin-io/docker-install-script/master/install.sh | sh
    
  2. Enable ip forwarding

    [root@alarmpi ~]# echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/40-ip-forward.conf

  3. Enable docker service at startup

    [root@alarmpi ~]# systemctl enable docker.service

  4. Reboot

    [root@alarmpi ~]# reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment