Docker Hubのpush / pullを試す

Docker Hubのpush / pullを試します。

## <i class="fa fa-flask" style="font-size:1em;"></i> サンプル
### <i class="fa fa-file-text" style="font-size:1em;"></i> 仕様
Base Image: [ubuntu:trusty - Docker Hub](https://hub.docker.com/_/ubuntu/)

### <i class="fa fa-files-o" style="font-size:1em;"></i> 手順
### <i class="fa fa-download" style="font-size:1em;"></i> Base Imageをpullする

```bash
$ docker pull ubuntu:trusty
```
### <i class="fa fa-download" style="font-size:1em;"></i> figletをインストールする

```bash
$ docker -i -t run ubuntu:trusty /bin/bash
$ root@29698f6e1480:~# apt-get update
$ root@29698f6e1480:~# apt-get install figlet
$ root@29698f6e1480:~# figlet hoge
 _                      
| |__   ___   __ _  ___ 
| '_ \ / _ \ / _` |/ _ \
| | | | (_) | (_| |  __/
|_| |_|\___/ \__, |\___|
             |___/      
```

### <i class="fa fa-refresh" style="font-size:1em;"></i> Docker Image を更新
```bash
$ docker commit -m "install figlet" -a "tbpgr" loving_morse tbpgr/figlet:v0.0.1
eb4f52e87176c1f38d40cb8fad83a6c8fc19b62bf330681f44de489f7877448c
$ docker images | grep figlet
tbpgr/figlet       v0.0.1              eb4f52e87176        About a minute ago   211.3 MB
```

### <i class="fa fa-upload" style="font-size:1em;"></i> Docker Image を Docker Hubに push
```bash
$ docker login
# ユーザー名、パスワード、メールアドレスで認証
WARNING: login credentials saved in /home/tbpgr/.docker/config.json
Login Succeeded

$ docker push tbpgr/figlet
The push refers to a repository [docker.io/tbpgr/figlet] (len: 1)
eb4f52e87176: Image successfully pushed 
91e54dfb1179: Image successfully pushed 
d74508fb6632: Image successfully pushed 
c22013c84729: Image successfully pushed 
d3a1f33e8a5a: Image successfully pushed 
v0.0.1: digest: sha256:d96fe99e5ae9da78895f82ae16dc945fae59a5a5e26d8f9912307fe1c5577714 size: 9231
```

### <i class="fa fa-desktop" style="font-size:1em;"></i> pushされたImageをDocker Hub上で確認
![docker_push.png](https://qiita-image-store.s3.amazonaws.com/0/43480/66ab711d-88d1-5425-e334-aca309d1960b.png)

### <i class="fa fa-search-plus" style="font-size:1em;"></i> pushされたImageはpublicになっているので検索可能
```bash
$ docker search tbpgr/figlet
NAME            DESCRIPTION   STARS     OFFICIAL   AUTOMATED
tbpgr/figlet 
```

### <i class="fa fa-key" style="font-size:1em;"></i> Docker HubのGUIでprivate リポジトリを登録する
![docker_private.png](https://qiita-image-store.s3.amazonaws.com/0/43480/9b8a0c27-a15d-5643-ddab-ef36adf93c06.png)


### <i class="fa fa-key" style="font-size:1em;"></i> Dockerでprivateをpushする
```bash
$ docker run -i -t ubuntu:trusty /bin/bash
$ root@29698f6e1480:~# apt-get update
$ root@29698f6e1480:~# apt-get install figlet
$ root@29698f6e1480:~# figlet hoge
 _                      
| |__   ___   __ _  ___ 
| '_ \ / _ \ / _` |/ _ \
| | | | (_) | (_| |  __/
|_| |_|\___/ \__, |\___|
             |___/    
```

```bash
$ docker commit -m "install figlet" -a "tbpgr" distracted_cori tbpgr/private:v0.0.1
2cc928e1e04d70ddb6dacbc1a4421f7420546fc79b74338d7eaf558dd8226c18
```

```bash
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
tbpgr/private      v0.0.1              2cc928e1e04d        3 seconds ago       209.6 MB
```

### <i class="fa fa-cloud-upload" style="font-size:1em;"></i> private リポジトリをpushする
```bash
$ docker push tbpgr/private
The push refers to a repository [docker.io/tbpgr/private] (len: 1)
2cc928e1e04d: Image successfully pushed 
ec18fd15e1f0: Image successfully pushed 
v0.0.1: digest: sha256:fe195dc2ffddee631397b591153e9c617ae67c4feeae949c3b0402d9fdbf5851 size: 2932
```

### <i class="fa fa-cloud-download" style="font-size:1em;"></i> private リポジトリをpullする
```bash
# private リポジトリ
$ docker pull tbpgr/private:v0.0.1
v0.0.1: Pulling from tbpgr/private
2cc928e1e04d: Pull complete 
ec18fd15e1f0: Already exists 
Digest: sha256:fe195dc2ffddee631397b591153e9c617ae67c4feeae949c3b0402d9fdbf5851
Status: Downloaded newer image for tbpgr/private:v0.0.1

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
tbpgr/private      v0.0.1              2cc928e1e04d        16 minutes ago      209.6 MB

$ docker run -i -t tbpgr/private:v0.0.1 /usr/bin/figlet hoge
 _                      
| |__   ___   __ _  ___ 
| '_ \ / _ \ / _` |/ _ \
| | | | (_) | (_| |  __/
|_| |_|\___/ \__, |\___|
             |___/      
```