Docker icon via wikipedia

本文环境

  • Raspberry Pi 3, Raspbian stretch
  • dockSwiftOnARM
  • Docker version 17.11.0-ce, build 1caf76c

什么是 Docker?

安装 Docker

安装与结果部分日志:

$ curl -sSL https://get.docker.com | sh

Client:
 Version:      17.11.0-ce
 API version:  1.34
 Go version:   go1.8.3
 Git commit:   1caf76c
 Built:        Mon Nov 20 19:01:07 2017
 OS/Arch:      linux/arm

Server:
 Version:      17.11.0-ce
 API version:  1.34 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   1caf76c
 Built:        Mon Nov 20 18:54:12 2017
 OS/Arch:      linux/arm
 Experimental: false

配置 Docker

开机自动启动

$ sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

手动启动可以使用以下命令:

$ sudo systemctl start docker

启动 Docker Client

Client 只能在 root 用户或在 docker 组用户使用,将 pi 用户添加到 docker 组:

sudo usermod -aG docker $USER

如果使用 ssh 登录,需要重新连接以生效。

使用 Docker

运行你的第一个 ARM 镜像(image)

$ docker run -ti arm32v6/alpine:3.5 /bin/sh
Unable to find image 'arm32v6/alpine:3.5' locally
3.5: Pulling from arm32v6/alpine
355842f7aa77: Pull complete
559bc1020041: Pull complete
Digest: sha256:5fcf00d09906e2ab2df5f421d066d992b44dc7690702b0abea7fd0dc0e130f72
Status: Downloaded newer image for arm32v6/alpine:3.5
/ # ls
ls     lsmod  lsof   lspci  lsusb
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.5.2
PRETTY_NAME="Alpine Linux v3.5"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org"
/ # echo "Hi, this is a tiny Linux distribution!" | base64
SGksIHRoaXMgaXMgYSB0aW55IExpbnV4IGRpc3RyaWJ1dGlvbiEK
/ # echo "SGksIHRoaXMgaXMgYSB0aW55IExpbnV4IGRpc3RyaWJ1dGlvbiEK" | base64 -d
Hi, this is a tiny Linux distribution!
/ # exit