====== Docker のインストール ======
Qiita にある、Raspberry-Pi へのインストールする記事 [[https://qiita.com/ksh-fthr/items/a26efd6fe06a174525a2|[Docker] RaspberryPi3 へのインストールからサンプル(hello-world)起動まで @Qiita]] ほぼそのまま実行することでインストールが可能です。\\
[[https://qiita.com/ksh-fthr|@ksh-fthr]] さん、ありがとうございます。
\\
===== リポジトリの設定 =====
==== パッケージの追加 ====
HTTPS 経由でパッケージのインストールができるようにするため、パッケージを追加します。
user1@plum:~$ sudo apt install apt-transport-https curl software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm
iso-codes libasn1-8-heimdal libassuan0 libcurl4 libgssapi3-heimdal libhcrypto4-heimdal
libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libkrb5-26-heimdal libksba8
libldap-2.4-2 libldap-common libnghttp2-14 libnpth0 libroken18-heimdal librtmp1 libsasl2-2
libsasl2-modules libsasl2-modules-db libwind0-heimdal pinentry-curses powermgmt-base
python-apt-common python3-apt python3-software-properties unattended-upgrades
Suggested packages:
dbus-user-session pinentry-gnome3 tor parcimonie xloadimage scdaemon isoquery
libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap
libsasl2-modules-otp libsasl2-modules-sql pinentry-doc python3-apt-dbg python-apt-doc bsd-mailx
default-mta | mail-transport-agent needrestart
The following NEW packages will be installed:
apt-transport-https curl dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client
gpg-wks-server gpgconf gpgsm iso-codes libasn1-8-heimdal libassuan0 libcurl4 libgssapi3-heimdal
libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libkrb5-26-heimdal
libksba8 libldap-2.4-2 libldap-common libnghttp2-14 libnpth0 libroken18-heimdal librtmp1 libsasl2-2
libsasl2-modules libsasl2-modules-db libwind0-heimdal pinentry-curses powermgmt-base
python-apt-common python3-apt python3-software-properties software-properties-common
unattended-upgrades
0 upgraded, 40 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,020 kB of archives.
After this operation, 29.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
... 略 ...
Setting up dirmngr (2.2.4-1ubuntu1.1) ...
Setting up libcurl4:armhf (7.58.0-2ubuntu3.5) ...
Setting up gpg-wks-client (2.2.4-1ubuntu1.1) ...
Setting up curl (7.58.0-2ubuntu3.5) ...
Setting up gnupg (2.2.4-1ubuntu1.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.9) ...
Processing triggers for dbus (1.12.2-1ubuntu1) ...
user1@plum:~$
\\
==== Docker GPG Key 追加 ====
Docker リポジトリの GPG Key を追加します。
user1@plum:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
user1@plum:~$
\\
==== Docker リポジトリの追加 ====
apt リポジトリに Docker 安定版リポジトリを追加します。
user1@plum:~$ sudo add-apt-repository "deb [arch=armhf] https://download.docker.com/linux/ubuntu bionic stable"
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Hit:2 http://ports.ubuntu.com/ubuntu-ports bionic InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports bionic-updates InRelease
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-security InRelease [83.2 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic/stable armhf Packages [3,152 B] <----- 追加されている
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic-security/main armhf Packages [150 kB]
Fetched 301 kB in 5s (64.0 kB/s)
Reading package lists... Done
user1@plum:~$
\\
===== インストール =====
==== Docker 最新版のインストール ====
Docker をインストールします。
user1@plum:~$ sudo apt install docker-ce
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apparmor aufs-tools cgroupfs-mount containerd.io docker-ce-cli git git-man iptables libcurl3-gnutls
liberror-perl libgdbm-compat4 libgdbm5 libip6tc0 libiptc0 libltdl7 libnetfilter-conntrack3
libnfnetlink0 libperl5.26 patch perl perl-modules-5.26 pigz
Suggested packages:
apparmor-profiles-extra apparmor-utils gettext-base git-daemon-run | git-daemon-sysvinit git-doc
git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn gdbm-l10n ed diffutils-doc
perl-doc libterm-readline-gnu-perl | libterm-readline-perl-perl make
The following NEW packages will be installed:
apparmor aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli git git-man iptables
libcurl3-gnutls liberror-perl libgdbm-compat4 libgdbm5 libip6tc0 libiptc0 libltdl7
libnetfilter-conntrack3 libnfnetlink0 libperl5.26 patch perl perl-modules-5.26 pigz
0 upgraded, 23 newly installed, 0 to remove and 0 not upgraded.
Need to get 40.3 MB of archives.
After this operation, 210 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 https://download.docker.com/linux/ubuntu bionic/stable armhf containerd.io armhf 1.2.0-1 [10.7 MB]
... 略 ...
Setting up docker-ce (5:18.09.0~3-0~ubuntu-bionic) ...
update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Setting up perl (5.26.1-6ubuntu0.3) ...
Setting up liberror-perl (0.17025-1) ...
Setting up git (1:2.17.1-1ubuntu0.4) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
user1@plum:~$
\\
Docker が起動していることを確認します。
user1@plum:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-12-18 15:15:55 JST; 1min 46s ago
Docs: https://docs.docker.com
Main PID: 2127 (dockerd)
Tasks: 11
CGroup: /system.slice/docker.service
└─2127 /usr/bin/dockerd -H unix://
Dec 18 15:15:48 plum dockerd[2127]: time="2018-12-18T15:15:48.343793182+09:00" level=warning msg="Your k
Dec 18 15:15:48 plum dockerd[2127]: time="2018-12-18T15:15:48.345844669+09:00" level=warning msg="Unable
Dec 18 15:15:48 plum dockerd[2127]: time="2018-12-18T15:15:48.354630623+09:00" level=info msg="Loading c
Dec 18 15:15:49 plum dockerd[2127]: time="2018-12-18T15:15:49.438301085+09:00" level=info msg="Default b
Dec 18 15:15:50 plum dockerd[2127]: time="2018-12-18T15:15:50.334482449+09:00" level=info msg="Loading c
Dec 18 15:15:54 plum dockerd[2127]: time="2018-12-18T15:15:54.594776910+09:00" level=warning msg="Not us
Dec 18 15:15:54 plum dockerd[2127]: time="2018-12-18T15:15:54.603429362+09:00" level=info msg="Docker da
Dec 18 15:15:54 plum dockerd[2127]: time="2018-12-18T15:15:54.608263345+09:00" level=info msg="Daemon ha
Dec 18 15:15:55 plum systemd[1]: Started Docker Application Container Engine.
Dec 18 15:15:55 plum dockerd[2127]: time="2018-12-18T15:15:55.179115643+09:00" level=info msg="API liste
起動していることが確認できました。
\\
===== 設定 =====
==== docker グループへの一般ユーザーの追加 ====
ユーザーの権限で Docker を利用する場合、ユーザーを **docker** グループへ追加しておきます。
user1@plum:~$ sudo usermod -a -G docker user1
user1@plum:~$
設定を有効にするため、一旦ログアウトして再度ログインする必要があります。
\\
===== テスト =====
Alpine Linux のイメージを取得し、起動してみます。
user1@plum:~$ docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
905674ea9d94: Pull complete
d91fe322e169: Pull complete
Digest: sha256:621c2f39f8133acb8e64023a94dbdf0d5ca81896102b9e57c0dc184cadaf5528
Status: Downloaded newer image for alpine:latest
user1@plum:~$
user1@plum:~$ docker run -it alpine
/ # cat /etc/issue
Welcome to Alpine Linux 3.8
Kernel \r on an \m (\l)
/ #
起動が確認できました。
別ターミナルからログインして、Docker の実行状態を確認してみます。
user1@plum:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bde6163e4f37 alpine "/bin/sh" 3 minutes ago Up 3 minutes vigorous_khorana
user1@plum:~$
問題なさそうです。
\\