LoginSignup
3
0

More than 1 year has passed since last update.

singularityでgitlab上のdocker imageをpullする

Last updated at Posted at 2022-01-19

概要

ABCIでdocker imageを使う際,実は公式に説明があるdockerhub以外のrepositoryからもimageをpullすることができると同僚に聞いたが,そのやり方がまとめられたページが見つからなかったのでメモを残す.

この記事が前提とする人

  1. Singularityが何かしっている. ABCIも知っている.
  2. Docker ImageがSingularity Imageに変換できることは知っている (参考)
  3. dockerhubが何かを知っている.
  4. gitlabのプロジェクトにdocker imageをpushできるらしいと知っている.

困り毎

ABCIの公式ドキュメントではdockerhub上にあるpublicなdocker imageをsingularityのimageに変換する(pullする)方法が説明されている.しかし,同僚によると任意のdocker repositoryのimageをpullできるらしい.

しかし,公式ドキュメントにあるコマンドでは特に指定なくdockerhubにつないでいるように見える.つなぐ先のdocker repositoryを指定する方法がよくわからない.
例えばgitlab上のdocker imageを使いたい場合,接続先をdockerhubからregistry.gitlab.com/<<path/to/your/docker_image>>変更する必要がある.(<>はdocker imageが格納されているプロジェクトのパス).

結論

ABCI上でpullをする前に singularity remote login でrepositoryにログインすれば良い.
具体的には下記のようなコマンドを実行する必要がある.

% module load singularitypro 
% singularity remote login --username <<gitlabのユーザ名>> docker://registry.gitlab.com
% singularity pull <destination>.sif docker://registry.gitlab.com/<<path/to/your/docker_image>>

ここで <> はABCIのディレクトリ内に作られる.sifイメージの任意の名前である.

<参考: Singularityの公式ドキュメント>


2022/3/8追記
なお,docker://を頭につけるのを忘れがちなので注意.
これを忘れると下記のようなエラーがでる. library: というのは docker://を指定しないことによりdefaultで設定されるimageファイルの探し場所のこと.自分で久しぶりに↑の作業をしてこのエラーに出くわし,メッセージの意味がわからずにう~んと5分くらい悩んでしまった.

FATAL:   While pulling library image: error fetching image: image does not exist in the library: <<path/to/your/docker_image>>:latest (amd64)

この作業をする上で上記以外でハマったところ

今回,そもそもgitlabのrepositoryにdocker imageをpushするのが初めてだった.
これを使用としたのだが, gitlab repository にdocker loginする際にエラーがでて困った.
エラーメッセージをよく読んだところ,作成してあったgitlab tokenでは api の項目が無効になっていたためにloginできないようだった.このため,gitlab tokenを「api」の項目にチェックをつけて再度作成した(ついでに全部チェックしてしまったが,誰かにtokenを渡すわけではないのでまぁ良いか...).

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