Raspberry Pi 4์— Ubuntu 20.04 LTS ๋ฐ Docker ์„ค์น˜

3ํ–‰ ์ •๋ฆฌ


  • Ubuntu Server 20.04 LTS ARM64 ๋ฒ„์ „์€ Raspberry Pi 4์—์„œ๋„ ๋ฌธ์ œ์—†์ด ์ž‘๋™ํ•œ๋‹ค.
  • Ubuntu ํ‘œ์ค€ Docker ํŒจํ‚ค์ง€๋„ ๋ฌธ์ œ์—†์ด ์ž‘๋™ํ•œ๋‹ค.
  • "Raspberry Pi Imager"๋Š” Homebrew์—์„œ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

  • 1. ์†Œ๊ฐœ



    2020๋…„ 4์›” 23์ผ์— ใ€ŒUbuntu 20.04 LTSใ€(๊ฐœ๋ฐœ ์ฝ”๋“œ: Focal Fossa)๊ฐ€ ๋ฆด๋ฆฌ์Šค ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    Kubernetes ํ™˜๊ฒฝ์„ ์—…๋ฐ์ดํŠธํ•˜๊ธฐ ์œ„ํ•ด Ubuntu 20.04 LTS๋ฅผ Raspberry Pi 4์— ์„ค์น˜ํ•˜๊ณ  Docker๋ฅผ ์„ค์น˜ํ–ˆ์Šต๋‹ˆ๋‹ค.
    ํŠนํžˆ ๋ฌธ์ œ์—๋Š” ์กฐ์šฐํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค๋งŒ, ์ผ๋‹จ ๊ธฐ๋กํ•ด ๋‘ก๋‹ˆ๋‹ค.

    2. ๊ตฌ์„ฑ



    ์ด๋ฒˆ ๊ตฌ์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • ํ•˜๋“œ์›จ์–ด: Raspberry Pi 4 2GB ๋ฒ„์ „
  • OS: Ubuntu Server 20.04 LTS ARM64(64๋น„ํŠธ) ๋ฒ„์ „

  • ์ด๋ฏธ์ง€์˜ ๊ธฐ์ž…์€, macOS 10.14.6(Mojave) ํ™˜๊ฒฝ์—์„œ ์‹ค์‹œํ–ˆ์Šต๋‹ˆ๋‹ค.
    mac$ sw_vers
    ProductName:    Mac OS X
    ProductVersion: 10.14.6
    BuildVersion:   18G103
    

    3. Ubuntu Server ์ด๋ฏธ์ง€ ๋‹ค์šด๋กœ๋“œ



    Raspberry Pi์šฉ "Ubuntu Server"์˜ ์ด๋ฏธ์ง€ "Install Ubuntu Server on a Raspberry Pi 2, 3 or 4"์—์„œ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.xz ํ˜•์‹์œผ๋กœ ์••์ถ•๋˜์–ด ์žˆ์ง€๋งŒ, ํ›„์ˆ ํ•˜๋Š” ใ€ŒRaspberry Pi Imagerใ€๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ, ์ „๊ฐœ๋Š” ๋ถˆํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

    ์ด๋ฒˆ ๋‹ค์šด๋กœ๋“œํ•œ ์ด๋ฏธ์ง€์˜ ์‚ฌ์ด์ฆˆ, ํ•ด์‹œ๊ฐ’(SHA-256)์€ ์ดํ•˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์•ฝ 667MiB.
    mac$ ls -l ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
    -rw-r--r--@ 1 yuya  staff  699424400 May  4 18:01 ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
    
    mac$ shasum -a 256 ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
    48167067d65c5192ffe041c9cc4958cb7fcdfd74fa15e1937a47430ed7b9de99  ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
    

    4. Ubuntu Server ์ด๋ฏธ์ง€๋ฅผ microSD ์นด๋“œ์— ์”๋‹ˆ๋‹ค.



    ๋‹ค์šด๋กœ๋“œํ•œ ์ด๋ฏธ์ง€๋ฅผ "Raspberry Pi Imager"๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ microSD ์นด๋“œ์— ์”๋‹ˆ๋‹ค.
    Raspberry Pi Imager๋Š” Raspberry Pi ๊ณต์‹ ์ด๋ฏธ์ง€ ์“ฐ๊ธฐ ๋„๊ตฌ๋กœ "Raspberry Pi Downloads"์—์„œ ๋‹ค์šด๋กœ๋“œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    Homebrew๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ cask๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    mac$ brew cask install raspberry-pi-imager
    ...
    ==> Downloading https://downloads.raspberrypi.org/imager/imager.dmg
    ######################################################################## 100.0%
    ==> No SHA-256 checksum defined for Cask 'raspberry-pi-imager', skipping verification.
    ==> Installing Cask raspberry-pi-imager
    ==> Moving App 'Raspberry Pi Imager.app' to '/Applications/Raspberry Pi Imager.app'.
    ๐Ÿบ  raspberry-pi-imager was successfully installed!
    

    Raspberry Pi Imager๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ์ด๋ฏธ์ง€ ํŒŒ์ผ, ์“ฐ๊ธฐ ๋Œ€์ƒ ์žฅ์น˜๋ฅผ ์„ ํƒํ•˜๊ณ  ๋ ˆ์ฝ”๋”ฉ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.



    ์ด Raspberry Pi์—๋Š” Kubernetes๋„ ๋„์ž…ํ•  ์˜ˆ์ •์ด๋ฏ€๋กœ ์ด๋ฏธ์ง€๋ฅผ ์“ด ํ›„ cgroup์˜ ์„ค์ •๋„ ์จ ๋‘ก๋‹ˆ๋‹ค.
    mac$ sed -i -e 's/$/ cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1/' /Volumes/system-boot/cmdline.txt
    mac$ cat /Volumes/system-boot/cmdline.txt
    net.ifnames=0 dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1
    

    5. Ubuntu Server ํ™˜๊ฒฝ ํ™•์ธ



    ์ด๋ฏธ์ง€๋ฅผ ์“ด microSD ์นด๋“œ๋ฅผ Raspberry Pi์— ๋„ฃ๊ณ  ๋ถ€ํŒ…ํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜์Œ ๋ถ€ํŒ…ํ•˜๋Š” ๋ฐ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฌ๋ฏ€๋กœ ๋กœ๊ทธ์ธ ํ™”๋ฉด์ด ํ‘œ์‹œ๋  ๋•Œ๊นŒ์ง€ ์ž ์‹œ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค. (Enter ํ‚ค๋ฅผ ๋ˆ„๋ฅด์ง€ ์•Š์œผ๋ฉด ๋กœ๊ทธ์ธ ํ™”๋ฉด์ด ํ‘œ์‹œ๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค)
    ๋˜ํ•œ, ๋””ํดํŠธ์˜ ์œ ์ €๋ช…์€ ubuntu , ํŒจ์Šค์›Œ๋“œ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ubuntu ์ž…๋‹ˆ๋‹ค.
    ์ฒ˜์Œ ๋กœ๊ทธ์ธํ•˜๋ฉด ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ผ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ํ‘œ์‹œ๋˜๋ฏ€๋กœ ์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

    ์ฐธ๊ณ ๋กœ, ๊ธฐ๋™ ์งํ›„์˜ ํ™˜๊ฒฝ์„ ์ดํ•˜์— ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
    ubuntu@ubuntu:~$ cat /etc/os-release
    NAME="Ubuntu"
    VERSION="20.04 LTS (Focal Fossa)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 20.04 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
    
    ubuntu@ubuntu:~$ uname -a
    Linux ubuntu 5.4.0-1008-raspi #8-Ubuntu SMP Wed Apr 8 11:13:06 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
    
    ubuntu@ubuntu:~$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            876M     0  876M   0% /dev
    tmpfs           185M  3.9M  181M   3% /run
    /dev/mmcblk0p2   30G  2.0G   26G   7% /
    tmpfs           925M     0  925M   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           925M     0  925M   0% /sys/fs/cgroup
    /dev/mmcblk0p1  253M   62M  191M  25% /boot/firmware
    /dev/loop0       24M   24M     0 100% /snap/snapd/7267
    /dev/loop1       49M   49M     0 100% /snap/core18/1708
    /dev/loop2       62M   62M     0 100% /snap/lxd/14808
    /dev/loop3       49M   49M     0 100% /snap/core18/1753
    tmpfs           185M     0  185M   0% /run/user/1000
    /dev/loop4       62M   62M     0 100% /snap/lxd/14894
    
    ubuntu@ubuntu:~$ cat /proc/cmdline
     coherent_pool=1M 8250.nr_uarts=1 cma=64M bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708_fb.fbswap=1 smsc95xx.macaddr=DC:A6:32:0A:62:1B vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 quiet splash
    
    ubuntu@ubuntu:~$ cat /proc/cpuinfo | grep Model
    Model       : Raspberry Pi 4 Model B Rev 1.1
    
    ubuntu@ubuntu:~$ cat /proc/meminfo | head -n 3
    MemTotal:        1892576 kB
    MemFree:          864424 kB
    MemAvailable:    1557632 kB
    

    6. Docker ์„ค์น˜



    Ubuntu ํ‘œ์ค€ ํŒจํ‚ค์ง€ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—๋Š” ์ตœ์‹  Docker(2020๋…„ 5์›” 4์ผ ํ˜„์žฌ v19.03.8) ํŒจํ‚ค์ง€๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
    ๋”ฐ๋ผ์„œ Docker์˜ Ubuntu ํŒจํ‚ค์ง€๊ฐ€ ์•„๋‹Œ Ubuntu ํ‘œ์ค€ ํŒจํ‚ค์ง€์—์„œ Docker๋ฅผ ์„ค์น˜ํ–ˆ์Šต๋‹ˆ๋‹ค.
    apt show docker.io ์˜ ๊ฒฐ๊ณผ์—๋Š” ์ดํ•˜์˜ ๊ธฐ์ˆ ์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ, ์ ์–ด๋„ ARM64 ํ™˜๊ฒฝ์—์„œ๋Š” ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    Using docker.io on non-amd64 hosts is not supported at this time.
    ubuntu@ubuntu:~$ sudo apt update
    ubuntu@ubuntu:~$ apt show docker.io
    Package: docker.io
    Version: 19.03.8-0ubuntu1
    Built-Using: glibc (= 2.31-0ubuntu4)
    Priority: optional
    Section: universe/admin
    Origin: Ubuntu
    Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
    Original-Maintainer: Paul Tagliamonte <paultag@debian.org>
    Bugs: https://bugs.launchpad.net/ubuntu/+filebug
    Installed-Size: 151 MB
    Depends: adduser, containerd (>= 1.2.6-0ubuntu1~), iptables, debconf (>= 0.5) | debconf-2.0, libc6 (>= 2.17), libdevmapper1.02.1 (>= 2:1.02.97), libseccomp2 (>= 2.1.0), libsystemd0 (>= 209~)
    Recommends: ca-certificates, cgroupfs-mount | cgroup-lite, git, pigz, ubuntu-fan, xz-utils, apparmor
    Suggests: aufs-tools, btrfs-progs, debootstrap, docker-doc, rinse, zfs-fuse | zfsutils
    Breaks: docker (<< 1.5~)
    Replaces: docker (<< 1.5~)
    Homepage: https://www.docker.com/community-edition
    Download-Size: 25.9 MB
    APT-Sources: http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages
    Description: Linux container runtime
     Docker complements kernel namespacing with a high-level API which operates at
     the process level. It runs unix processes with strong guarantees of isolation
     and repeatability across servers.
     .
     Docker is a great building block for automating distributed systems:
     large-scale web deployments, database clusters, continuous deployment systems,
     private PaaS, service-oriented architectures, etc.
     .
     This package contains the daemon and client. Using docker.io on non-amd64 hosts
     is not supported at this time. Please be careful when using it on anything
     besides amd64.
     .
     Also, note that kernel version 3.8 or above is required for proper operation of
     the daemon process, and that any lower versions may have subtle and/or glaring
     issues.
    
    ubuntu@ubuntu:~$ sudo apt install --yes docker.io
    ubuntu@ubuntu:~$ sudo docker version
    Client:
     Version:           19.03.8
     API version:       1.40
     Go version:        go1.13.8
     Git commit:        afacb8b7f0
     Built:             Wed Mar 11 23:43:15 2020
     OS/Arch:           linux/arm64
     Experimental:      false
    
    Server:
     Engine:
      Version:          19.03.8
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.13.8
      Git commit:       afacb8b7f0
      Built:            Wed Mar 11 22:48:33 2020
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          1.3.3-0ubuntu2
      GitCommit:
     runc:
      Version:          spec: 1.0.1-dev
      GitCommit:
     docker-init:
      Version:          0.18.0
      GitCommit:
    

    7. hello-world ์ด๋ฏธ์ง€ ์‹คํ–‰



    Docker ์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฏ€๋กœ ๋™์ž‘ ํ™•์ธ์„ ์œ„ํ•ด hello-world ์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•ด ๋ด…๋‹ˆ๋‹ค.
    ubuntu@ubuntu:~$ sudo docker container run --tty --rm hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    256ab8fe8778: Pull complete
    Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
    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.
        (arm64v8)
     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/
    

    ์„ฑ๊ณต์ ์œผ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
    Ubuntu Server์™€ Docker ์„ค์น˜๋Š” ์ด์ƒ์ž…๋‹ˆ๋‹ค.

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ