LoginSignup
1
1

More than 5 years have passed since last update.

MiniShiftのBoot2Dockerで内部レジストリにdocker pushできなくて苦労した話

Last updated at Posted at 2017-12-02

MiniShiftは普段使っているパソコンでOpenShiftの動作確認ができるので重宝しています。

oc new-appコマンドで簡単にアプリケーションをデプロイできるのですが、手動でDockerImageをOpenShiftの内部レジストリにpushした際に下記のように「 unauthorized: authentication required 」と認証できなくて先に進む事ができなくて一時期悩んでました。

$ docker push $(minishift openshift registry)/test01/busybox:latest
The push refers to a repository [172.30.1.1:5000/test01/busybox]
0271b8eebde3: Preparing
unauthorized: authentication required

本件はMiniShiftのgithubのissues 「Authentication required when trying to push to OpenShift registry #817」には登録(2017年4月)されているのですが、現時点では解決していなく回避策を見つけるまで結構時間がかかったので備忘録を兼ねて投稿します。

事象を確認した環境

  • Linux

    • CentOS7.4 + KVM
  • Mac

    • macOS Sierra + xhyve
  • minishift

    • v1.6.0+7a71565

原因 と回避策

11月下旬にGitHubのMiniShiftのdocsに追加された Authentication required to push image to OpenShift integrated Docker registry によると

  • 原因
    ホストのDockerClientとMiniShiftが起動したVM内のDockerDaemonと互換性がないため事象が発生していてる。

  • 回避策
    Fedora、CentOSまたはRHELで使用している場合は、CentOS ISOを使用する。

MiniShftは起動するとLive ISOイメージ使ってハイパーバイザーから MiniShift VMをプロビジョニングをします。現在以下の3つの Live ISOが提供されている中で

  • Minishift Boot2Docker (Default)
  • Minishift CentOS
  • minikube

デフォルトで起動するBoot2Dockerから Minishift CentOS に変更すれば回避できます。具体的には MiniShiftの起動コマンドを 「 minishift start 」から 「 minishift start --iso-url centos 」に変更します。

回避策の確認

実際に下記の手順で確認を行いました。

  • 現在動作している MinSsihft(Boot2Docker)のVM停止と削除
$ minishift stop
$ minishift delete
You are deleting the Minishift VM: 'minishift'. Do you want to continue [y/N]?:
Deleting the Minishift VM...
Minishift VM deleted.
  • Minishiftを Live isoイメージを Minishift CentOS 指定で起動する。
$ minishift start --iso-url centos
-- Checking if KVM driver is installed ...
   Driver is available at /usr/local/bin/docker-machine-driver-kvm ...
   Checking driver binary is executable ... OK
-- Starting local OpenShift cluster using 'kvm' hypervisor ...
-- Minishift VM will be configured with ...
   Memory:    2 GB
   vCPUs :    2
   Disk size: 20 GB

   Downloading ISO 'https://github.com/minishift/minishift-centos-iso/releases/download/v1.2.0/minishift-centos7.iso'

  • developerユーザでログインして test01プロジェクトを作成
$ oc login -u developer
$ oc new-project test01
  • DockerHubからbusyboxをpullしてOpenShiftの内部レジストリにpushする
$ docker pull busybox
$ docker login -u developer -p $(oc whoami -t) $(minishift openshift  registry)
Login Succeeded
$ docker tag docker.io/busybox $(minishift openshift registry)/test01/busybox:latest
$ docker push $(minishift openshift registry)/test01/busybox:latest
The push refers to a repository [172.30.1.1:5000/test01/busybox]
0271b8eebde3: Pushed
latest: digest: sha256:91ef6c1c52b166be02645b8efee30d1ee65362024f7da41c404681561734c465
                                          size: 527

「 Pushed 」の出力から無事pushできてことが確認できました。

最後に

fedora/CentOS/REHLだけかと思ったら私のmacOS Sierra + xhyveの環境でも事象が発生しています。
いつかは解消すると思いますが、もし事象に遭遇した時にこの投稿でトラブルシューティングする時間が短縮されると幸いです。

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