Skip to content

Docker Services

Iman Saleh edited this page Dec 22, 2015 · 3 revisions

Wiki HomeDocker Services

Docker services

For development and testing purposes. Docker services is a service broker that allows you to add services easily to Cloud Foundry.

Adding a docker image into docker services

In the Properties of a docker image manifest, there is a list of "services" properties. This is used to add the docker image as a service.

      - id: '617b9186-2e5b-11e4-af5d-a6c5e4d22fb7'
        name: 'rethinkdb'
        description: 'RethinkDB is built to store JSON documents'
        bindable: true
        tags:
          - 'rethinkdb'
          - 'document'
        metadata:
          displayName: 'RethinkDB 1.14.0'
          imageUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAAAAACPAi4CAAAETWlDQ1BJQ0MgUHJvZmlsZQAAOBGFVU1sG1UQHmfXDqrCigO0VSuVJ/5aRWm0CRQSKqCunTppItfND5BSFW3Xz/HWm91ld+02UU+5kBNUAiGuIIR6A4GoWn7U5tJeiqhUBVTIBalIrQAJAao4AOKb9dpZh0PWevb35s3Mm/lmxkvUfdHwPLtLEM07oV+YzM6+PHtMdN+gLtKoh/AYZuBlS6UJxo7rSP7tfO59SymW3NzLvjrPNt2lyzIwoXUFyy0H5jxRSifK9JmeHxJ1H4d86HToMX4b+MHa9GQO+DywFtsC0kMF6UjfMkXBNxZEyXcrlp2MdbNz9rHpM2/XOVZ+dmH1BLWpcfz2IuYzVX90EvhZ4PdNY2QKuA94zQsPshw6XffVazPZprxrsOIfmonlJxar0y8BPwCdZSscmwbuB37XOVk8Eutfrbnj7Gc75L+bQe4Y8GNEypaqHOPaCOD+ssyPACMGpVitj7J/+FGWg8YUyxlfWKzmisC4S7l9yjhcAt4K/KfvTvJdjxCpW6Rd4LvgX+3zwhLLh4BLjl3ku5CLuiyDKMc9wJ+E1enRWP/70J9mW/bzb8U6NAYMHtLCs6Meehp4wq9PcmxPAC8Z/kgBGH7S56Uzw7wxvlE28sztU8B/0YspgyS5dBLfJjn0D/INyKJGhDzycVbB3qYCNBwsn6zU/VSDTFDyvGVnURUnIewcrAYZVIqsml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msjY97T2lAPFh8xNuctQcFvjjpAfIykHLFqLagvbGBpz13T1w/3RLS8y1fXF/UQuNQCax7Vt+/fPd0BtO5ILSO66iD+A1VceC6BDTdyAAAAAElFTkSuQmCC'
          longDescription: 'RethinkDB is built to store JSON documents'
          providerDisplayName: 'RethinkDB'
          documentationUrl: 'http://rethinkdb.com/'
          supportUrl: 'http://rethinkdb.com/'
        requires: []
        dashboard_client:
          id: 'rethinkdb-dashboard'
          secret: 'rethinkdb-dashboard-secret'
          redirect_uri: (( meta.cfcontainersbroker.external_host "/manage/auth/cloudfoundry/callback" ))
        plans:
          - id: '6194d79a-2e5b-11e4-af5d-a6c5e4d22fb7'
            name: 'free'
            container:
              backend: 'docker'
              image: 'dockerfile/rethinkdb'
              tag: 'latest'
              persistent_volumes:
                - '/data'
            credentials:
              uri:
                prefix: 'rethinkdb'
                port: '28015/tcp'
            description: 'Free Trial'
            metadata:
              costs:
                - amount:
                    usd: 0.0
                  unit: 'MONTHLY'
              bullets:
                - 'Dedicated RethinkDB 1.14.0 server'
                - 'RethinkDB 1.14.0 running inside a Docker container'

This is an example of a single service. In this case, RethinkDB.

      - id: '617b9186-2e5b-11e4-af5d-a6c5e4d22fb7'
        name: 'rethinkdb'
        description: 'RethinkDB is built to store JSON documents'
        bindable: true
        tags:
          - 'rethinkdb'
          - 'document'

This setup ID is a UUID that has to be unique across your different services. Name, description, and bindable are required. Tags are used to return back to application for certain tag for service.

metadata:
          displayName: 'RethinkDB 1.14.0'
          imageUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAAAAACPAi4CAAAETWlDQ1BJQ0MgUHJvZmlsZQAAOBGFVU1sG1UQHmfXDqrCigO0VSuVJ/5aRWm0CRQSKqCunTppItfND5BSFW3Xz/HWm91ld+02UU+5kBNUAiGuIIR6A4GoWn7U5tJeiqhUBVTIBalIrQAJAao4AOKb9dpZh0PWevb35s3Mm/lmxkvUfdHwPLtLEM07oV+YzM6+PHtMdN+gLtKoh/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eBIEcG0e6EygjZapdOfPRjn2WFAhAHQCmr7gHCs9+dOg4DlSbXQpQFhItXMFNER4W/QZvKFbciXbvs38hMnHrk4Y0/KFGkh87cc90tJ009phoNGFozdgrt0kEa/maRZJtvHJEWAFS7atummUN46qu5ZhdbjAVir8r6C6/+qQgAYx/OZBvPIB6AK4M/77tpE0RW7niz1NHEiRgXxPGXH/xyf0V1dG7sHS91NhJiAYJQPDQpvjOEP4zn3nn2fC7Uj+JdkCEvD+79DBxCz+RwKRu2Id4CUYNm3/hxSZI29H+SX0qFCK0AWOfrnvtVpQPjw19fqyd0QisAYC2T3O6kA6PNx+aT+ndOSwCgWTi300uH5w+H0qE1AEQ6nJi44abDK/tLuaATTQByOSgi0+GLt2qKwI09O84HEyoMsLVFM9GGIBw6yJnsUYx3vPvChcC3lg5AMNRnHgv1uvLgvs/tFTG/9sAzc/LKUENvaVX45ba6eRJnoOrKiF8ye7fP5NUSz+Ut30TU/msjY97T2lAPFh8xNuctQcFvjjpAfIykHLFqLagvbGBpz13T1w/3RLS8y1fXF/UQuNQCax7Vt+/fPd0BtO5ILSO66iD+A1VceC6BDTdyAAAAAElFTkSuQmCC'
          longDescription: 'RethinkDB is built to store JSON documents'
          providerDisplayName: 'RethinkDB'
          documentationUrl: 'http://rethinkdb.com/'
          supportUrl: 'http://rethinkdb.com/'

The Metadata section is used for images, description, and URLs that can be used in a front-end dashboard to display services.

        requires: []
        dashboard_client:
          id: 'rethinkdb-dashboard'
          secret: 'rethinkdb-dashboard-secret'
          redirect_uri: (( meta.cfcontainersbroker.external_host "/manage/auth/cloudfoundry/callback" ))

The dashboard URL is used if the service needs an oauth client.

plans:
          - id: '6194d79a-2e5b-11e4-af5d-a6c5e4d22fb7'
            name: 'free'
            container:
              backend: 'docker'
              image: 'dockerfile/rethinkdb'
              tag: 'latest'
              persistent_volumes:
                - '/data'
            credentials:
              uri:
                prefix: 'rethinkdb'
                port: '28015/tcp'
            description: 'Free Trial'
            metadata:
              costs:
                - amount:
                    usd: 0.0
                  unit: 'MONTHLY'
              bullets:
                - 'Dedicated RethinkDB 1.14.0 server'
                - 'RethinkDB 1.14.0 running inside a Docker container'

Each plan must have a UUID. Container has all the information about the container, such as image, tags, where persistent disk is stored. Metadata is used for billing if needed.

            credentials:
              username:
                key: 'POSTGRES_USERNAME'
              password:
                key: 'POSTGRES_PASSWORD'
              dbname:
                key: 'POSTGRES_DBNAME'
              uri:
                prefix: 'postgres'

Credentials are environment variables that need to be set for an image to generate credentials. These are generated by the docker services on every new image. These are returned to the app as credentials. The URI prefix is if you want a URI generated as a credential.

When new services are added, the following commands need to be run:

cf create-service-broker docker containers containers <broker url>
# List services
cf service-access
cf enable-service-access <service_name>
Clone this wiki locally