LoginSignup
1
0

More than 5 years have passed since last update.

Docker概要3 - Engineのインストール

Posted at

はじめに

これから書いていくDocker関連記事の大きな目的は以下の2点です。
社内用に適当に書いた資料ですが何かの役に立つかもしれないのでこちらにも投稿しておこうかなっていう記事です。

  • Dockerについての情報を、教育目線でまとめることでDockerに対する理解を深めること。
  • 社内のDocker普及を目的として、ざっくりとした概要を社内のドキュメント環境に設置しておくこと。

概要

この記事ではDockerEngineをCentOSホストにインストールする手順についてメモを残します。

Dockerのインストール

yumを利用してインストールが可能なので、dockerのrepositoryを追加してyumインストールを実行します。

# sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

# yum install docker-engine

テスト用イメージの実行

# docker run hello-world

実行後、Localに該当のDockerイメージが有るか確認し、なければDockerHubからPullしてきます。
なお、以下のメッセージはLocalにイメージが存在する場合は出力されず、即座にイメージが実行されます。

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest

Downloadに成功すると、自動的に以下のメッセージを出力してコンテナは停止します。

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

そして最下部に記載のあるようにコマンドを実行することでUbuntuのDockerイメージを起動することが可能となります。

インストールされたDockerの確認

さて、インストールと動作確認までできたところでどのようにインストールされたのかざっくり見てみましょう。
docker info コマンドで現状のDockerの様子を知ることができます。

$ docker info
Containers: 19
 Running: 0
 Paused: 0
 Stopped: 19
Images: 11
Server Version: 17.05.0-ce
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-693.11.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 2.781GiB
Name: instance-1
ID: 4JSW:FSHD:2OGN:HVYI:WSLC:X3HP:YFYX:EAEA:TXHH:T6GI:7ABQ:S7JC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

ストレージドライバ

一つ認識しておいていただきたいのは、ストレージドライバは現状AUFSではなくなっているらしいことです。
イメージとコンテナのレイヤ構造自体は以下それぞれの機能でもって実現されている模様。

Storage Driver: overlay

現状は以下の6つが利用できるようです。
ストレージフォーマットによるらしいので詳細は公式などのドキュメントで確認してくださいネ。
 docker-docs-jp

技術 ストレージドライバ名
OverlayFS overlay または overlay2
AUFS aufs
Btrfs btrfs
Device Mapper devicemapper
VFS* vfs
ZFS zfs

dockerd自体の設定はSystemdで変更する

掲題のとおり、DockerEngine自体の設定変更はsystemdを用いて行います。
ExecStartのコマンドに各種オプションを付加することで起動時に利用するドライバや各種の設定が行えるわけです。
 docker-docs-jp

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0