docs/apidocs/cloud-api-source/source/includes/repository.md

5.6 KiB

External Repositories

External Repository

Example

{
  "in_use": false, 
  "name": "quay.io/tutum/ubuntu", 
  "registry": "/api/repo/v1/registry/quay.io/", 
  "resource_uri": "/api/repo/v1/repository/quay.io/tutum/ubuntu/", 
}

The repository endpoint is used to add and remove existing repositories on third party registries to be used in deployments and builds.

Attributes

Attribute Description
resource_uri A unique API endpoint that represents the repository
name Name of the repository, i.e. quay.io/tutum/ubuntu
in_use If the image is being used by any of your services
registry Resource URI of the registry where this image is hosted

List all external repositories

import dockercloud

repositories = dockercloud.Repository.list()
GET /api/repo/v1/repository/ HTTP/1.1
Host: cloud.docker.com
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
Accept: application/json
import "github.com/docker/go-dockercloud/dockercloud"

repositoriesList, err := dockercloud.ListRepositories()

if err != nil {
    log.Println(err)
}

log.Pringln(repositoriesList)
docker-cloud repository ls

Lists all added repositories from third party registries. Returns a list of Repository objects.

Endpoint Type

Available in Docker Cloud's REST API

HTTP Request

GET /api/repo/v1/repository/

Query Parameters

Parameter Description
name Filter by image name
registry Filter by resource URI of the target repository registry

Add a new external repository

import dockercloud

repository = dockercloud.Repository.create(name="registry.local/user1/image1", username=username, password=password)
repository.save()
POST /api/repo/v1/repository/ HTTP/1.1
Host: cloud.docker.com
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
Accept: application/json
Content-Type: application/json

{"name": "registry.local/user1/image1", "username": "username", "password": "password"}
import "github.com/docker/go-dockercloud/dockercloud"

image, err := dockercloud.CreateImage(dockercloud.ImageCreateRequest{
  Name: "registry.local/user1/image1",
  Username: "username",
  Password: "password"
})
docker-cloud repository register -u username -p password registry.local/user1/image1

Adds an existing repository on a third party registry.

Endpoint Type

Available in Docker Cloud's REST API

HTTP Request

POST /api/repo/v1/repository/

JSON Parameters

Parameter Description
name Name of the repository, i.e. 'quay.io/tutum/hello-world'
username Username to authenticate with the third party registry
password Password to authenticate with the third party registry

Get an external repository details

import dockercloud

repository = dockercloud.Repository.fetch("registry.local/user1/image1")
GET /api/repo/v1/repository/registry.local/user1/image1/ HTTP/1.1
Host: cloud.docker.com
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
Accept: application/json
import "github.com/docker/go-dockercloud/dockercloud"

repository, err = dockercloud.GetRepository("registry.local/user1/image1")

if err != nil {
    log.Println(err)
}

log.Println(repository)
docker-cloud repository inspect registry.local/user1/image1

Gets all the details of an specific repository

Endpoint Type

Available in Docker Cloud's REST API

HTTP Request

GET /api/repo/v1/repository/(name)/

Path Parameters

Parameter Description
name The name of the repository to retrieve

Update credentials of an external repository

import dockercloud

repository = dockercloud.Repository.fetch("registry.local/user1/image1")
repository.username = "new username"
repository.password = "new password"
repository.save()
PATCH /api/repo/v1/repository/registry.local/user1/image1/ HTTP/1.1
Host: cloud.docker.com
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
Accept: application/json
Content-Type: application/json

{"username": "username", "password": "password"}
docker-cloud repository update -n "new username" -p "new password" registry.local/user1/image1

Updates the external repository credentials.

Endpoint Type

Available in Docker Cloud's REST API

HTTP Request

PATCH /api/repo/v1/repository/(name)/

Path Parameters

Parameter Description
name The name of the repository to update

JSON Parameters

Parameter Description
username Username to authenticate with the private registry
password Password to authenticate with the private registry

Remove an external repository

import dockercloud

repository = dockercloud.Repository.fetch("registry.local/user1/image1")
repository.delete()
DELETE /api/repo/v1/repository/registry.local/user1/image1/ HTTP/1.1
Host: cloud.docker.com
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
Accept: application/json
import "github.com/docker/go-dockercloud/dockercloud"

repository, err = dockercloud.GetRepository("registry.local/user1/image1")

if err != nil {
    log.Println(err)
}

repository.Remove()
docker-cloud repository rm registry.local/user1/image1

Removes the external repository from Docker Cloud. It won't remove the repository from the third party registry where it's stored.

Endpoint Type

Available in Docker Cloud's REST API

HTTP Request

DELETE /api/repo/v1/repository/registry.local/user1/image1/

Path Parameters

Parameter Description
name The name of the external repository to remove