2

I currently have a workflow that goes like this: Bitbucket -> Wercker.

Wercker correctly builds my app, but when it comes to deploying I am lost. I am attempting to deploy to my IBM Containers registry on Bluemix (recently out of beta). Running docker login registry.ng.bluemix.net with my IBM account credentials returns a 401: bad credentials on my local machine (boot2docker on OSX). It does the same on Wercker in my deploy step. Here is my deploy step:

deploy:
  box:
    id: node
    tag: 0.12.6-slim
  steps:
    - internal/docker-push:
            username: $USERNAME
            password: $PASSWORD
            tag: main
            entrypoint: node bundle/main.js
            repository: <my namespace/<my container name> (removed for this post)
            registry: registry.ng.bluemix.net

As you can see: I have the username and password passed in as environment variables as per the Wercker Docs (and I have tested that they are passed in correctly).

Basically: how do you push containers to an IBM registry WITHOUT using the ice/cf CLI? I have a feeling that I'm missing something obvious. I just can't find it.

James Thomas
  • 4,303
  • 1
  • 20
  • 26
Luke Adams
  • 213
  • 1
  • 8

4 Answers4

3

You need to use either the Containers plugin for cf or the ICE tool to login.

Documentation

Cloud Foundry plug-in: cf ic login ICE: ice login

Can you create a custom script that can log in first? If the environment already has cf with the containers extension:

- script:
    name: Custom login for Bluemix Containers
    code: cf login -u <username> -p <password> -o <org> -s <space>

Excuse my wercker newb.

Ram Vennam
  • 3,536
  • 1
  • 12
  • 19
  • I don't think Wercker reads any docker configurations created in the build environment (which itself runs within docker), but I'll report back when I get a chance. – Luke Adams Jul 08 '15 at 07:13
  • Yup - sort of. ice uses cf to grab a token, then attempts to initialize docker (wont work on Wercker). cf will save the token to disk (outside of the buildroot ;) ) so you can extract it and set it as an environment variable for the push. – Luke Adams Jul 10 '15 at 02:53
  • And thanks - you got me started on the right track. I didn't even think to try straight up cf in the deploy environment. – Luke Adams Jul 10 '15 at 03:04
1

The problem is that the authentication with the registry uses a token rather than your userID and password. ice login and cf ic login take care of that but unfortunately a straight up docker login won't work.

Some scripts for initializing, building and cleaning up images are also available here: https://github.com/Osthanes/docker_builder. These are used in the DevOps Services delivery pipeline which is likely a similar flow to what you are building.

1

Turns out: it's very possible.

Basically:

  • Install CF cli
  • cf login -a https://api.ng.bluemix.net
  • Extract token from ~/.cf/config.json (text after bearer in AccessToken + "|" + OrganizationFields.Guid

It depends what you want to do with it. I have a very detailed write-up here on Github. You can use the token as the password, passing 'bearer' as the username.

@mods: Is this enough for me to link to another site? I really hate to duplicate stuff like this...

Luke Adams
  • 213
  • 1
  • 8
0

You can now generate tokens to access the IBM Bluemix Container Registry using the container-registry plugin for the bx command.

These tokens can be read-only or read-write and either non-expiring (unless revoked) or expire after 24 hours.

The tokens can be used directly with docker login.

Read the docs here

timgp
  • 79
  • 8