mirror of https://github.com/docker/docs.git
274 lines
5.6 KiB
Markdown
274 lines
5.6 KiB
Markdown
# External Repositories
|
|
|
|
## External Repository
|
|
|
|
> Example
|
|
|
|
```json
|
|
{
|
|
"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
|
|
|
|
```python
|
|
import dockercloud
|
|
|
|
repositories = dockercloud.Repository.list()
|
|
```
|
|
|
|
```http
|
|
GET /api/repo/v1/repository/ HTTP/1.1
|
|
Host: cloud.docker.com
|
|
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
|
|
Accept: application/json
|
|
```
|
|
|
|
```go
|
|
import "github.com/docker/go-dockercloud/dockercloud"
|
|
|
|
repositoriesList, err := dockercloud.ListRepositories()
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
|
|
log.Pringln(repositoriesList)
|
|
```
|
|
|
|
```shell
|
|
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
|
|
|
|
```python
|
|
import dockercloud
|
|
|
|
repository = dockercloud.Repository.create(name="registry.local/user1/image1", username=username, password=password)
|
|
repository.save()
|
|
```
|
|
|
|
```http
|
|
POST /api/repo/v1/repository/ HTTP/1.1
|
|
Host: cloud.docker.com
|
|
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
|
|
```
|
|
|
|
```go
|
|
import "github.com/docker/go-dockercloud/dockercloud"
|
|
|
|
image, err := dockercloud.CreateImage(dockercloud.ImageCreateRequest{
|
|
Name: "registry.local/user1/image1",
|
|
Username: "username",
|
|
Password: "password"
|
|
})
|
|
```
|
|
|
|
```shell
|
|
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
|
|
|
|
```python
|
|
import dockercloud
|
|
|
|
repository = dockercloud.Repository.fetch("registry.local/user1/image1")
|
|
```
|
|
|
|
```http
|
|
GET /api/repo/v1/repository/registry.local/user1/image1/ HTTP/1.1
|
|
Host: cloud.docker.com
|
|
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
|
|
Accept: application/json
|
|
```
|
|
|
|
```go
|
|
import "github.com/docker/go-dockercloud/dockercloud"
|
|
|
|
repository, err = dockercloud.GetRepository("registry.local/user1/image1")
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
|
|
log.Println(repository)
|
|
```
|
|
|
|
```shell
|
|
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
|
|
|
|
```python
|
|
import dockercloud
|
|
|
|
repository = dockercloud.Repository.fetch("registry.local/user1/image1")
|
|
repository.username = "new username"
|
|
repository.password = "new password"
|
|
repository.save()
|
|
```
|
|
|
|
```http
|
|
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
|
|
|
|
```
|
|
|
|
```shell
|
|
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
|
|
|
|
```python
|
|
import dockercloud
|
|
|
|
repository = dockercloud.Repository.fetch("registry.local/user1/image1")
|
|
repository.delete()
|
|
```
|
|
|
|
```http
|
|
DELETE /api/repo/v1/repository/registry.local/user1/image1/ HTTP/1.1
|
|
Host: cloud.docker.com
|
|
Authorization: Basic dXNlcm5hbWU6YXBpa2V5
|
|
Accept: application/json
|
|
```
|
|
|
|
```go
|
|
import "github.com/docker/go-dockercloud/dockercloud"
|
|
|
|
repository, err = dockercloud.GetRepository("registry.local/user1/image1")
|
|
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
|
|
repository.Remove()
|
|
```
|
|
|
|
```shell
|
|
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
|