(O+P)ut

アウトプット



(O+P)ut

エンジニアのアウトプット

【ICCR】sysdig/secure-inline-scanでThe login credentials are not valid, or your IBM Cloud account is not activeと出るエラー

スポンサーリンク

事象

自前でアップロードしたICCRレジストリのイメージにSysdigSecureのスキャンを利用するも

# docker run --rm quay.io/sysdig/secure-inline-scan:2 jp.icr.io/xx/xx:1.2 --sysdig-token xx --sysdig-url https://jp-tok.monitoring.cloud.ibm.com/

以下のエラーで失敗する。

Using imageID as primary identifier
Inspecting image from remote repository -- xx

ERROR:
Failed to retrieve the image specified in script input - xx
Please pull remote image, or build/tag all local images before attempting analysis again.
time="xx" level=fatal msg="Error parsing image name \"docker://jp.icr.io/xx\": unable to retrieve auth token: invalid username/password: unauthorized: The login credentials are not valid, or your IBM Cloud account is not active."

尚、docker pull単体では成功する。

# docker pull jp.icr.io/xx/xx:1.3
環境情報
# docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12

原因/解決策

IBM Cloud Container Registryの認証用に利用している以下のファイルをコンテナ内に配置して

# cat .docker/config.json
{
        "auths": {
                "jp.icr.io": {
                        "auth": "xx",
                        "identitytoken": "xx"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/19.03.5 (linux)"
        }
}

認証を通す。

具体的には以下のマウントとコンフィグの指定を行うと

# docker run -v /root/.docker/config.json:/home/anchore/.docker/config.json --rm quay.io/sysdig/secure-inline-scan:2 jp.icr.io/xx/xx:1.3 --sysdig-token xx --sysdig-url https://jp-tok.monitoring.cloud.ibm.com/ --registry-auth-file /home/anchore/.docker/config.json

コマンドが成功した。

Using imageID as primary identifier
...
  Writing manifest to image destination
  Storing signatures
Analyzing image...
Analysis complete! ...

以下は補足です。

補足

同コマンドの引数に以下がありますが

--registry-auth-file      <PATH>             Path to config.json or auth.json file with registry credentials

このコマンドはコンテナ内のパスを指しているようです。
よってmountコマンドでコンテナ内に配置して同オプションを利用しました。

ちなみに実際の失敗例も乗せておきます。

# docker run --rm quay.io/sysdig/secure-inline-scan:2 jp.icr.io/xx/xx:1.3 --sysdig-token xx --sysdig-url https://jp-tok.monitoring.cloud.ibm.com/ --registry-auth-file /root/.docker/config.json
...
ERROR:
Failed to retrieve the image specified in script input - xx
Please pull remote image, or build/tag all local images before attempting analysis again.
time="xx" level=fatal msg="Error parsing image name \"docker://jp.icr.io/xx\": error getting username and password: error reading JSON file \"/root/.docker/config.json\": open /root/.docker/config.json: permission denied"
# docker run -v /root/.docker/config.json:/home/anchore/.docker/config.json --rm quay.io/sysdig/secure-inline-scan:2 jp.icr.io/xx/xx:1.3 --sysdig-token xx --sysdig-url https://jp-tok.monitoring.cloud.ibm.com/
...
ERROR:
Failed to retrieve the image specified in script input - xx.
Please pull remote image, or build/tag all local images before attempting analysis again.
time="xx" level=fatal msg="Error parsing image name \"docker://jp.icr.io/xx\": unable to retrieve auth token: invalid username/password: unauthorized: The login credentials are not valid, or your IBM Cloud account is not active."

以上、ご参考ください。