Docker/Install for Linux Mint

Linux Mint 19.1 を使用。2019年3月ごろに実施。

Linux Mint は Ubuntu系なのでそちらのドキュメントが使えると思われる。

https://docs.docker.com/install/linux/docker-ce/ubuntu/

まず apt をアップデートする

$ sudo apt update

必要になる周辺ツールをインストールする

$ sudo apt install apt-transport-https
$ sudo apt install ca-certificates
$ sudo apt install curl
$ sudo apt install gnupg-agent
$ sudo apt install software-properties-common

ca-certificates, curl は Linux Mint では初期状態でもう入っていた。

Docker のリポジトリのキーを追加する

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

キーの確認

$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [  不明  ] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

確かにドキュメントに提示されている 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 と一致している。

リポジトリの追加。64it安定版はこのようだ。

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

しかしこれはダメっぽい。$(lsb_release -cs) この部分が Ubuntu のバージョンを示しているようだが Linux Mint 19.1 ではこの内容は tessa となる。tessa は Linux Mint 19.1のコードネーム

Linux Mint 19.1 は Ubuntu 18.04.1 にあたり

開発コードをの対応はこうなっている

リリースバージョン コードネーム
Ubuntu 16.04 xenial
Ubuntu 16.10 yakkety
Ubuntu 17.04 zesty
Ubuntu 17.10 artful
Ubuntu 18.04 bionic
Ubuntu 18.10 cosmic
Ubuntu 19.04 disco

こうなので bionic が必要だとわかる。

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

この情報はこのへんに書き込まれているので

/etc/apt/source.list.d/additional-repositories.list

中身をこのように書き換える

deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

OK

$ sudo apt update

ということでインストールする

$ sudo apt-get install docker-ce

ドキュメントでは3つのパッケージを指定しているが、依存性解決で最初の1つだけで後は自動的に入る。

終了。

おもむろに実行する

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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.
    (amd64)
 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/

この説明を見るに docker コマンド、つまり Docker のクライアントを使って daemon に指示を与えた。

hello-world イメージが無いので daemon は Docker Hub という Docker Image の共通リポジトリみたいなところからダウンロードしたと

新しいコンテナを Image から作成した。

daemon はこのメッセージを出力した。と。

hello-world イメージは起動して実行したら終わったらすぐ終了している。

ではこれをやってみる。このオプションでクライアントと対話的に繋がることになる。

amazon linux 2 を起動する。当然持ってないのでダウンロードから始まる

$ sudo docker run -i -t amazonlinux:2 /bin/bash

Bash を指定して起動している

プロンプトが立ち上がるので、コマンドを打ってみる。

bash-4.2# ls
bin  boot  dev	etc  home  lib	lib64  local  media  mnt  opt  proc  root  run	sbin  srv  sys	tmp  usr  var
bash-4.2# whoami
root

普通に動く。

別のシェルから実行しているコンテナを覗いてみる。

$ sudo docker container list    
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
f10a87b3b5f0        amazonlinux:2       "/bin/bash"         37 minutes ago      Up 37 minutes                           gifted_jang

確かに動いている。

抜ける。

bash-4.2# exit

止まった

$ sudo docker container list    
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

こんなもんでいいだろう。

linux/distribution/linux_mint/linux_mint_19_1_mate/docker/install.txt · 最終更新: 2020-06-26 11:23 by ore