1

I am deploying docker applications to cloud foundry running on the swisscom cloud (website). Here's a snippet from my deployment script.

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

So far so good, the app gets created and starts without any problems.

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   

But if the app crashes and CF attempts to restart it I get the following error.

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

How can I get CF to restart the app successfully?

1 Answers1

2

I'm using gitlab ci to deploy to cloud foundry.
The docker images are stored in gitlab's docker registry and I authenticated with a password provided by gitlab during the build ($CI_REGISTRY_PASSWORD).

As it turns out, this is only a temporary password and is no longer valid when cloud foundry attempts to restart an application. I'm using a personal access token instead of the provided login and now it works perfectly.

  • 1
    FYI only. From the CF side, that's the expected behavior. CF not only needs the password for the registry when you `cf push` but also any time your app is restarted, by a user (like `cf restart`) or by the foundation (like a crash). – Daniel Mikusa Feb 25 '19 at 16:36