centos7 docker-ce install

# 公式

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


# 手順メモ

rootでログインした前提なので他のユーザーならsudoをつける。

## 手順

docker インストールに必要なもの

```
[root@ ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
```

yumできるようにする

```
[root@ ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
```

インストール可能なdockerのバージョンを確認

```
[root@ ~]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            18.03.1.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos            @docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
Installed Packages
Available Packages
 * updates: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * epel: mirror.dmmlabs.jp
 * base: ftp.iij.ad.jp
```

docker install (最新)

```
[root@ ~]# yum install docker-ce
```

docker install (バージョン指定)

```
[root@ ~]# yum install docker-ce-<VERSION STRING>
```

docker 起動

```
[root@ ~]# systemctl start docker
```

dockerのバージョン確認

```
[root@ ~]# docker --version
Docker version 18.03.1-ce, build 9ee9f40
```

docker で hello world

```
[root@ ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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サービスを自動起動に設定

```
[root@ ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
```