0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GCP内のコンテナイメージを高速ダウンロードする手順

Posted at

GCP内のコンテナイメージを高速ダウンロードする手順

Google Cloud Platform の「Container Registry」に保存されている非公開のコンテナイメージを自分のローカルパソコンに高速でダウンロードする方法をメモしておきます。
コンテナイメージをネット上で公開せずに、別の開発者の方に渡す際に利用できる方法かと思います。

Google Cloud Shellにある「cloudshell download」でダウンロードする手順を試しましたが500MBで30分以上かかってイライラしたので、別の方法がないか模索している内に見つけた手順です。

※ダウンロードしたファイルの整合性などは未確認ですので自己責任でお願いします。

GCPコンソールで対象コンテナイメージの「pullコマンド」をコピーしてくる

docker pull gcr.io/project-name001/cont-img-manage-pilot:latest

GCPコンソール画面の右上にあるCloud ShellアイコンをクリックしCloud Shellを起動

先ほどコピーしたPullコマンドを実行。

MyAccountName@cloudshell:~$ docker images

取得したコンテナイメージを確認。

REPOSITORY                                        TAG       IMAGE ID       CREATED        SIZE
gcr.io/project-name001/cont-img-manage-pilot   latest    ee67c3b1f999   5 months ago   1.27GB

コンテナイメージの保存

取得したコンテナイメージは、Cloud Shell用の一時的な仮想VMのどこかに保存されているので、これをtar形式で保存?書き出し?を行う。
自分のルートディレクトリに保存、1.27GBもあるので数秒かかる。

MyAccountName@cloudshell:~$ docker save gcr.io/project-name001/cont-img-manage-pilot:latest -o cont-img-manage-pilot.tar

一時的なHTTPサーバーで公開してダウンロード

このファイルを一時的なHTTPサーバーで公開してダウンロードさせる。

一時的なHTTPサーバーで公開するディレクトリをtmp配下に作成して移動

MyAccountName@cloudshell:~$ cd `mktemp -d`

公開ディレクトリに対象ファイルを移動させる

MyAccountName@cloudshell:/tmp/tmp.GPPKd6UX8R$ cp -Rp /home/MyAccountName/cont-img-manage-pilot.tar ./

一時的なHTTPサーバーを起動させる

MyAccountName@cloudshell:/tmp/tmp.GPPKd6UX8R$ python -m SimpleHTTPServer 8080

問題無く起動すると下記の様な表示がでてくる。

********************************************************************************
Python 2 is deprecated. Upgrade to Python 3 as soon as possible.
See https://cloud.google.com/python/docs/python2-sunset

To suppress this warning, create an empty ~/.cloudshell/no-python-warning file.
The command will automatically proceed in  seconds or on any key.
********************************************************************************
Serving HTTP on 0.0.0.0 port 8080 ...

Cloud Shellは現状のまま置いておいて、自分アイコンの左2個隣りの「ウェブプレビュー」アイコンからクリック
「ポート8080でプレビュー」をクリックするとウェブページが開く

この様な感じでダウンロードが可能になる。
ダウンロードが完了したらCloud Shellで「Ctrl + c」でHTTPサーバーを終了させる

1.27GBを約10分ほどでダウンロードできたので、そこそこ良い方法なのかもしれない。
※ダウンロードしたファイルの整合性などは未確認ですので自己責任でお願いします。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?