如何从私有存储库重新启动Cloud Foundry Docker应用?

时间:2019-02-25 12:01:13

标签: docker authentication cloudfoundry swisscomdev

我正在将docker应用程序部署到swisscom云(website)上运行的Cloud Foundry。这是我的部署脚本的一个片段。

...
export CF_DOCKER_PASSWORD=$CI_REGISTRY_PASSWORD
cf push $APP_NAME -f "$MANIFEST_FILE" --vars-file $VARS_FILE

到目前为止,该应用程序已成功创建并启动,没有任何问题。

Waiting for app to start...

name:              app_name
requested state:   started
routes:            app_name.scapp.io
last uploaded:     Mon 25 Feb 11:55:01 UTC 2019
stack:             
docker image:      registry.gitlab.com/org_name/app_name:master

type:            web
instances:       1/1
memory usage:    192M
start command:   npm start
     state     since                  cpu     memory          disk           details
#0   running   2019-02-25T11:55:45Z   13.3%   95.7M of 192M   974.7M of 3G   

但是,如果应用程序崩溃并且CF尝试重新启动它,则会出现以下错误。

2019-02-25 12:34:01 [CELL/0] OUT Cell 9f61c89b-5496-4f3a-a332-74084c0db365 creating container for instance 7f8762ce-d004-425e-729f-bfbd
2019-02-25 12:34:04 [CELL/0] ERR Cell 9f61c89b-5496-4f3a-a332-74084c0db365 failed to create container for instance 7f8762ce-d004-425e-729f-bfbd: running image plugin create: fetching image reference: creating image: unable to retrieve auth token: invalid username/password
2019-02-25 12:34:04 [CELL/0] ERR : exit status 1

manifest.yml

---
applications:
- name: app_name
  memory: 192M
  instances: 1
  disk_quota: 3G
  routes:
    app_name.scapp.io
  docker:
    image: registry.gitlab.com/org_name/app_name:master
    username: registry_user_here

如何获取CF以成功重新启动应用程序?

1 个答案:

答案 0 :(得分:2)

我正在使用gitlab ci部署到Cloud Foundry。
docker映像存储在gitlab的docker注册表中,我在构建期间使用gitlab提供的密码进行了身份验证($CI_REGISTRY_PASSWORD)。

事实证明,这只是一个临时密码,在Cloud Foundry尝试重新启动应用程序时不再有效。我使用的是个人访问令牌,而不是所提供的登录名,现在它可以正常使用了。