Ubuntu18.04にDockerをインストール
公式による解説:
Get Docker CE for Ubuntu | Docker Documentation
の通りにインストールしていきます.
Dockerとは
先日,素晴らしいまとめが作られていました.
冷凍チャーハンを用いて直感的にDockerを理解したい方へ
インストール
もし,古いバージョンがある場合はアンインストールしておく
$ sudo apt-get remove docker docker-engine docker.io
aptをアップデートしておく
$ sudo apt-get update
必要なパッケージをインストール
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common
Docker公式のGPG公開鍵をインストール. GPGとは,GNU Privacy Guard の略で,暗号化だけでなく署名や認証といったオンライン上の機密や信用を管理するツールのようです.パッケージを入手する側は,GPGキーを使って署名を復号化し,パッケージが正しいかどうかを確認できるとのこと.
以下のようにOKが表示されます.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - OK
公開鍵のフィンガープリントを確認
$ 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) sub rsa4096 2017-02-22 [S]
apt
コマンド用のリポジトリを設定する.
Dockerには,stable
, edge
, test
の3種類が公開されていて,ここでは安定版であるstable
を選択します.
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
Docker CEのインストール
ちなみに,商用版Docker EE(Enterprise Edition)の登場に伴い,従来の無料版がDocker CE(Community Edition)と呼ばれているようです.
$ sudo apt-get update $ sudo apt-get install docker-ce
Dockerがきちんとインストールされていることを確認するため,run
コマンドでhello-world
を表示してみます.
$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9bb5a5d4561a: Pull complete Digest: sha256:f5233545e435612qwrq161e77 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/engine/userguide/
バージョン確認
$ docker version
インストールができたら次は
機械学習の開発環境をコンテナにしてみるとか:
DockerでPython3.6の環境構築!matplotlibインストールで詰まった話とかも
DockerでPythonの実行環境を作ったメモ | mwSoft
オープンソースWebアプリをコピーして試してみるとか:
Dockerで即実行できる、社内・自宅向けオープンソースWebアプリ
色々と遊べそうです.