Red Hat Container Catalog
「Red Hat Container Catalog」とは、Red Hat が提供するコンテナカタログのこと
ここにあるコンテナイメージをminishiftのOpenShift Namespaceにインポートします。
これにより、いままでの例ではプロジェクト内に一度イメージを登録してから
PodのBuildやDeployを行っていましたが、この前作業が不要になります。
Red Hat Container CatalogのコンテナイメージをPullする
Red Hat Container CatalogでPythonのイメージを検索すると色々出てきますが、割と新し目のこちらを登録することにします。
rhscl/python-36-rhel7
Python 3.6 platform for building and running applications
by Red Hat, Inc. | in Product Red Hat Enterprise Linux
[tak@centos76 ~]$ minishift ssh
[docker@minishift ~]$ docker login registry.connect.redhat.com --username=<userid> --password=<password>
Login Succeeded
[docker@minishift ~]$ docker search registry.access.redhat.com/rhscl/python-36-rhel7
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
redhat.com registry.access.redhat.com/rhscl/python-36-rhel7 Python 3.6 available as container is a bas... 0
[docker@minishift ~]$ docker pull registry.access.redhat.com/rhscl/python-36-rhel7
Using default tag: latest
Trying to pull repository registry.access.redhat.com/rhscl/python-36-rhel7 ...
latest: Pulling from registry.access.redhat.com/rhscl/python-36-rhel7
23113ae36f8e: Pull complete
d134b18b98b0: Pull complete
e9c030a1a5e3: Pull complete
784f9bf04822: Pull complete
8daef2dd454c: Pull complete
Digest: sha256:28b0dcad1b420b83f1d5ab6e05f9eaaf3db74b1264c56971409b6dd9d279f162
Status: Downloaded newer image for registry.access.redhat.com/rhscl/python-36-rhel7:latest
PullしたDocker ImageをPushする
まずはsystem/adminのクレデンシャルを取得します。
[tak@centos76 ~]$ oc login $(minishift ip):8443 -u system -p admin
Login successful.
You don't have any projects. You can try to create a new project, by running
oc new-project <projectname>
[tak@centos76 ~]$ oc whoami -t
O8lC2QsDLR00JQdzf3JSUsfNA02LhfpRoGw****NXUY
内部レジストリにログインします。
[tak@centos76 ~]$ minishift ssh
Last login: Thu Jan 10 13:48:17 2019 from 192.168.42.1
[docker@minishift ~]$ docker login -u system -p O8lC2QsDLR00JQdzf3JSUsfNA02LhfpRoGw****NXUY 172.30.1.1:5000
Login Succeeded
172.30.1.1:5000
は内部レジストリでminishift openshift registry
でIPポートが判るはずなのですが…
[tak@centos76 ~]$ minishift openshift registry
No information found for 'service/docker-registry'
確認は簡単なところでいくとdocker images
でdocker.io
ではないIPとポートになります。
[docker@minishift ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/openshift/origin-control-plane v3.11.0 577b017e619b 6 days ago 825 MB
docker.io/openshift/origin-hyperkube v3.11.0 8d1d4be00ef1 6 days ago 506 MB
docker.io/openshift/origin-hypershift v3.11.0 6edfe453cc9e 6 days ago 546 MB
<none> <none> a259c0dc4a42 7 days ago 832 MB
docker.io/openshift/origin-control-plane <none> 6b44b5168ffe 10 days ago 825 MB
docker.io/openshift/origin-hypershift <none> 28075fb43c17 10 days ago 546 MB
docker.io/openshift/origin-hyperkube <none> 4ec01d866344 10 days ago 506 MB
docker.io/openshift/origin-node v3.11.0 438d61da63d1 2 weeks ago 1.16 GB
docker.io/openshift/origin-control-plane <none> 00f980c345c1 2 weeks ago 825 MB
docker.io/openshift/origin-hyperkube <none> d65ee3cc9874 2 weeks ago 506 MB
docker.io/openshift/origin-docker-builder v3.11.0 320e0c77623c 2 weeks ago 458 MB
docker.io/openshift/origin-haproxy-router v3.11.0 316c2621011d 2 weeks ago 407 MB
docker.io/openshift/origin-pod v3.11.0 045ddf827c75 2 weeks ago 258 MB
docker.io/openshift/origin-deployer v3.11.0 d05e619aac21 2 weeks ago 380 MB
docker.io/openshift/origin-hypershift <none> a777d85d24b9 2 weeks ago 546 MB
docker.io/openshift/origin-cli v3.11.0 83d7b0b2f011 2 weeks ago 380 MB
172.30.1.1:5000/openshift/python <none> 8c84620ebb62 4 weeks ago 686 MB
172.30.1.1:5000/openshift/postgresql <none> 2dea7cba1c67 5 weeks ago 343 MB
172.30.1.1:5000/openshift/nginx <none> 4165cf0bbf2b 5 weeks ago 322 MB
docker.io/centos/s2i-base-centos7 latest 8e5a167a93a2 5 weeks ago 518 MB
registry.access.redhat.com/rhscl/mariadb-101-rhel7 latest a4deee8ed5a5 6 weeks ago 455 MB
registry.access.redhat.com/rhscl/python-36-rhel7 latest 8c2f91ba249e 6 weeks ago 627 MB
registry.connect.redhat.com/bitnami/wordpress-nginx-php7 latest 2892cd4d344e 8 weeks ago 580 MB
docker.io/openshift/origin-web-console v3.11.0 be30b6cce5fa 2 months ago 339 MB
docker.io/openshift/origin-docker-registry v3.11.0 a0d5ad164395 2 months ago 305 MB
docker.io/openshift/origin-service-serving-cert-signer v3.11 47dadf9d43b6 2 months ago 276 MB
docker.io/openshift/base-centos7 latest 4842f0bd3d61 23 months ago 383 MB
PullしてきたDocker Imageタグを付けます。
[docker@minishift ~]$ docker tag registry.access.redhat.com/rhscl/python-36-rhel7 172.30.1.1:5000/openshift/python-36-rhel7
いよいよPushします。
[docker@minishift ~]$ docker push 172.30.1.1:5000/openshift/python-36-rhel7:latest
The push refers to a repository [172.30.1.1:5000/openshift/python-36-rhel7]
9d0ec22e98e7: Preparing
c0fd37436dc2: Preparing
f695f001025f: Preparing
ab9227d97750: Preparing
56a763045c45: Preparing
unauthorized: authentication required
あれ...最後に怒られてますね...。
docker push で unauthorized: authentication required
と怒られる
Google先生に聞いてみたら同じ事象で問題を抱えてられる方がいるようで
「DockerHubにPushするときに認証エラーが発生したときの対処方法」@youhei_nakagawa
どうやら.docker/config.jsonを修正すると良いそうな
"docker.io": {
↓
"https://index.docker.io/v1/": {
わたしの環境を覗いてみると
[docker@minishift ~]$ more .docker/config.json
{
"auths": {
"172.30.1.1:5000": {
"auth": "c3lzdGVtOjFYSFZuM0FSdmRvTTg0WDRmWUpHOXJKdTc1UGdNcHdsc****jVGSU5KdU0="
}
}
これをこの様に編集
[docker@minishift ~]$ more .docker/config.json
{
"auths": {
"https://172.30.1.1:5000/v1/": {
"auth": "c3lzdGVtOjFYSFZuM0FSdmRvTTg0WDRmWUpHOXJKdTc1UGdNcHdsc****jVGSU5KdU0="
}
}
再度Push
[docker@minishift ~]$ docker push 172.30.1.1:5000/openshift/python-36-rhel7:latest
The push refers to a repository [172.30.1.1:5000/openshift/python-36-rhel7]
9d0ec22e98e7: Preparing
c0fd37436dc2: Preparing
f695f001025f: Preparing
ab9227d97750: Preparing
56a763045c45: Preparing
unauthorized: authentication required
やっぱり認証がいるって怒られます。
後から分かったのですがこの~/.docker/config.json
はdocker login
する度に増えていくので
ダメ元でIPそのまま、v1,v2とやってみたのですがやっぱり駄目
[docker@minishift ~]$ docker login --username=system --password=1XHVn3ARvdoM84X4fYJG9rJu75PgMpwlsu-****NJuM 172.30.1.1:5000
Login Succeeded
[docker@minishift ~]$ docker login --username=system --password=1XHVn3ARvdoM84X4fYJG9rJu75PgMpwlsu-****NJuM https://172.30.1.1:5000/v1/
Login Succeeded
[docker@minishift ~]$ docker login --username=system --password=1XHVn3ARvdoM84X4fYJG9rJu75PgMpwlsu-****NJuM https://172.30.1.1:5000/v2/
]Login Succeeded
[docker@minishift ~]$ more .docker/config.json
{
"auths": {
"172.30.1.1:5000": {
"auth": "c3lzdGVtOjFYSFZuM0FSdmRvTTg0WDRmWUpHOXJKdTc1UGdNcHdsc****jVGSU5KdU0="
},
"https://172.30.1.1:5000/v1/": {
"auth": "c3lzdGVtOjFYSFZuM0FSdmRvTTg0WDRmWUpHOXJKdTc1UGdNcHdsc****jVGSU5KdU0="
},
"https://172.30.1.1:5000/v2/": {
"auth": "c3lzdGVtOjFYSFZuM0FSdmRvTTg0WDRmWUpHOXJKdTc1UGdNcHdsc****jVGSU5KdU0="
}
}
}
[docker@minishift ~]$ docker push 172.30.1.1:5000/django2/python-36-rhel7:latest
The push refers to a repository [172.30.1.1:5000/django2/python-36-rhel7]
9d0ec22e98e7: Preparing
c0fd37436dc2: Preparing
f695f001025f: Preparing
ab9227d97750: Preparing
56a763045c45: Preparing
unauthorized: authentication required
試しに172.30.1.1:5000
をdocker.io
に替えてみましたがログインも駄目
[docker@minishift ~]$ docker tag registry.access.redhat.com/rhscl/python-36-rhel7 docker.io/openshift/python-36-rhel7
[docker@minishift ~]$ docker images | grep ^docker
docker.io/openshift/origin-control-plane v3.11.0 577b017e619b 6 days ago 825 MB
docker.io/openshift/origin-hyperkube v3.11.0 8d1d4be00ef1 6 days ago 506 MB
docker.io/openshift/origin-hypershift v3.11.0 6edfe453cc9e 6 days ago 546 MB
docker.io/openshift/origin-control-plane <none> 6b44b5168ffe 10 days ago 825 MB
docker.io/openshift/origin-hypershift <none> 28075fb43c17 10 days ago 546 MB
docker.io/openshift/origin-hyperkube <none> 4ec01d866344 10 days ago 506 MB
docker.io/openshift/origin-node v3.11.0 438d61da63d1 2 weeks ago 1.16 GB
docker.io/openshift/origin-control-plane <none> 00f980c345c1 2 weeks ago 825 MB
docker.io/openshift/origin-hyperkube <none> d65ee3cc9874 2 weeks ago 506 MB
docker.io/openshift/origin-docker-builder v3.11.0 320e0c77623c 2 weeks ago 458 MB
docker.io/openshift/origin-haproxy-router v3.11.0 316c2621011d 2 weeks ago 407 MB
docker.io/openshift/origin-pod v3.11.0 045ddf827c75 2 weeks ago 258 MB
docker.io/openshift/origin-deployer v3.11.0 d05e619aac21 2 weeks ago 380 MB
docker.io/openshift/origin-hypershift <none> a777d85d24b9 2 weeks ago 546 MB
docker.io/openshift/origin-cli v3.11.0 83d7b0b2f011 2 weeks ago 380 MB
docker.io/centos/s2i-base-centos7 latest 8e5a167a93a2 5 weeks ago 518 MB
docker.io/openshift/python-36-rhel7 latest 8c2f91ba249e 6 weeks ago 627 MB
docker.io/openshift/origin-web-console v3.11.0 be30b6cce5fa 2 months ago 339 MB
docker.io/openshift/origin-docker-registry v3.11.0 a0d5ad164395 2 months ago 305 MB
docker.io/openshift/origin-service-serving-cert-signer v3.11 47dadf9d43b6 2 months ago 276 MB
docker.io/openshift/base-centos7 latest 4842f0bd3d61 23 months ago 383 MB
[docker@minishift ~]$ docker login --username=system --password=1XHVn3ARvdoM84X4fYJG9rJu75PgMpwlsu-****NJuM docker.io
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
[docker@minishift ~]$ docker login --username=system --password=1XHVn3ARvdoM84X4fYJG9rJu75PgMpwlsu-****NJuM https://registry-1.docker.io/v2/:
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
[docker@minishift ~]$ docker push docker.io/openshift/python-36-rhel7:latest
The push refers to a repository [docker.io/openshift/python-36-rhel7]
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
有識者の方、助けて…(T_T)
[tak@centos76 ~]$ minishift version
minishift v1.29.0+72fa7b2
[tak@centos76 ~]$ oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://192.168.42.246:8443
kubernetes v1.11.0+d4cacc0
結局挫折して自分のプロジェクトにインポート
自分のプロジェクトを使うためにログインして
[tak@centos76 ~]$ oc login $(minishift ip):8443 -u developer
Login successful.
You have one project on this server: "myproject"
Using project "myproject".
インポート
[tak@centos76 ~]$ oc import-image python-36-rhel7:latest --from=registry.access.redhat.com/rhscl/python-36-rhel7 --confirm
imagestream.image.openshift.io/python-36-rhel7 imported
Name: python-36-rhel7
Namespace: myproject
Created: 26 hours ago
Labels: <none>
Annotations: openshift.io/image.dockerRepositoryCheck=2019-01-12T05:52:39Z
Docker Pull Spec: 172.30.1.1:5000/myproject/python-36-rhel7
Image Lookup: local=false
Unique Images: 1
Tags: 1
latest
tagged from registry.access.redhat.com/rhscl/python-36-rhel7
* registry.access.redhat.com/rhscl/python-36-rhel7@sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
26 hours ago
Image Name: python-36-rhel7:latest
Docker Image: registry.access.redhat.com/rhscl/python-36-rhel7@sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
Name: sha256:bc3538e03e4b8c60dbeb806e02b24360a389bd65a12ff73f55328eedfbcdcb3e
Created: 1 second ago
Annotations: image.openshift.io/dockerLayersOrder=ascending
Image Size: 222.1MB in 5 layers
Layers: 75.72MB sha256:23113ae36f8e9d98b1423e44673979132dec59db2805e473e931d83548b0be82
1.223kB sha256:d134b18b98b0d113b7b1194a60efceaa2c06eff41386d6c14b0e44bfe557eee8
6.795MB sha256:e9c030a1a5e35aacb0fe94238025996b812bafcc8c1422a35d7bda1223da6e9e
86.37MB sha256:784f9bf048226aaa367d5784fcf90628254eb9c6998d72e894a525c4399d4c38
53.24MB sha256:8daef2dd454ce803baaa827469d1ef3c6e0342422f61bac311021a15fa4cf7ce
Image Created: 6 weeks ago
Author: <none>
Arch: amd64
Entrypoint: container-entrypoint
Command: /bin/sh -c $STI_SCRIPTS_PATH/usage
Working Dir: /opt/app-root/src
User: 1001
Exposes Ports: 8080/tcp
Docker Labels: architecture=x86_64
authoritative-source-url=registry.access.redhat.com
build-date=2018-11-26T07:27:36.337423
com.redhat.build-host=cpt-0010.osbs.prod.upshift.rdu2.redhat.com
com.redhat.component=rh-python36-container
description=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
distribution-scope=public
io.k8s.description=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
io.k8s.display-name=Python 3.6
io.openshift.expose-services=8080:http
io.openshift.s2i.scripts-url=image:///usr/libexec/s2i
io.openshift.tags=builder,python,python36,rh-python36
io.s2i.scripts-url=image:///usr/libexec/s2i
maintainer=SoftwareCollections.org <sclorg@redhat.com>
name=rhscl/python-36-rhel7
release=36
summary=Platform for building and running Python 3.6 applications
url=https://access.redhat.com/containers/#/registry.access.redhat.com/rhscl/python-36-rhel7/images/1-36
usage=s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.6/test/setup-test-app/ rhscl/python-36-rhel7 python-sample-app
vcs-ref=96351017867feb48429a2dc98ecdd27fc450960c
vcs-type=git
vendor=Red Hat, Inc.
version=1
Environment: PATH=/opt/app-root/src/.local/bin/:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
container=oci
SUMMARY=Platform for building and running Python 3.6 applications
DESCRIPTION=Python 3.6 available as container is a base platform for building and running various Python 3.6 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
STI_SCRIPTS_URL=image:///usr/libexec/s2i
STI_SCRIPTS_PATH=/usr/libexec/s2i
APP_ROOT=/opt/app-root
HOME=/opt/app-root/src
BASH_ENV=/opt/app-root/etc/scl_enable
ENV=/opt/app-root/etc/scl_enable
PROMPT_COMMAND=. /opt/app-root/etc/scl_enable
NODEJS_SCL=rh-nodejs8
PYTHON_VERSION=3.6
PYTHONUNBUFFERED=1
PYTHONIOENCODING=UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
PIP_NO_CACHE_DIR=off