Docker Hubのpush / pullを試す

  • 9
    いいね
  • 0
    コメント
この記事は最終更新日から1年以上が経過しています。

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

サンプル

仕様

Base Image: ubuntu:trusty - Docker Hub

手順

Base Imageをpullする

$ docker pull ubuntu:trusty

figletをインストールする

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

Docker Image を更新

$ 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

Docker Image を Docker Hubに push

$ 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

pushされたImageをDocker Hub上で確認

docker_push.png

pushされたImageはpublicになっているので検索可能

$ docker search tbpgr/figlet
NAME            DESCRIPTION   STARS     OFFICIAL   AUTOMATED
tbpgr/figlet 

Docker HubのGUIでprivate リポジトリを登録する

docker_private.png

Dockerでprivateをpushする

$ docker run -i -t ubuntu:trusty /bin/bash
$ root@29698f6e1480:~# apt-get update
$ root@29698f6e1480:~# apt-get install figlet
$ root@29698f6e1480:~# figlet hoge
 _                      
| |__   ___   __ _  ___ 
| '_ \ / _ \ / _` |/ _ \
| | | | (_) | (_| |  __/
|_| |_|\___/ \__, |\___|
             |___/    
$ docker commit -m "install figlet" -a "tbpgr" distracted_cori tbpgr/private:v0.0.1
2cc928e1e04d70ddb6dacbc1a4421f7420546fc79b74338d7eaf558dd8226c18
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
tbpgr/private      v0.0.1              2cc928e1e04d        3 seconds ago       209.6 MB

private リポジトリをpushする

$ 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

private リポジトリをpullする

# 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
 _                      
| |__   ___   __ _  ___ 
| '_ \ / _ \ / _` |/ _ \
| | | | (_) | (_| |  __/
|_| |_|\___/ \__, |\___|
             |___/