debian stretchにdockerをインストール
作業
既存バージョンのアンインストール(新規インストールの場合は不要)
すでにインストールしているdockerを削除します。
$ sudo apt-get remove docker docker-engine
Docker レポジトリのセットアップ
必要なパッケージをインストールします。
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ software-properties-common
次にDockerの公式GPG鍵を追加します
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
レポジトリを追加します
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable"
dockerのインストール
パッケージリストの更新
$ sudo apt-get update
パッケージのインストール
$ sudo apt-get install docker-ce
動作テスト
$ sudo docker run hello-world
以下のように表示されればOK
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. 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://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
番外編(kvmのブリッジと共存)
動機
すでにkvmの仮想環境を持っている状態でdockerをインストールしたときにハマったのでまとめておきます。
状況として,ネットワーク構成は br0 を建てて,物理NICのeno1と仮想NIC vnet*がぶら下がっている構成です。
ここにdockerをインストールするとDocker用のブリッジはdocker0が作成されてbr0と干渉してしまいました。
仮想マシンのネットワークが使えなくなるどころか,すべてのネットワークが正常に稼働しなくなるのでこれを解消します。
方針
docker0を削除してbr0にすべてのブリッジ接続を集約します。
以下の公式ドキュメントを参考にしました
Build your own bridge | Docker Documentation