Skip to main content

docker_credentials

Creates, updates, deletes, gets or lists a docker_credentials resource.

Overview

Namedocker_credentials
TypeResource
Iddigitalocean.container_registry.docker_credentials

Fields

The following fields are returned by SELECT queries:

A Docker config.json file for the container registry.

NameDatatypeDescription
registry.digitalocean.comobject

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
registries_get_docker_credentialsselectregistry_nameIn order to access your container registry with the Docker client or from a
Kubernetes cluster, you will need to configure authentication. The necessary
JSON configuration can be retrieved by sending a GET request to
/v2/registries/{registry_name}/docker-credentials.

The response will be in the format of a Docker config.json file. To use the
config in your Kubernetes cluster, create a Secret with:

kubectl create secret generic docr <br /> --from-file=.dockerconfigjson=config.json <br /> --type=kubernetes.io/dockerconfigjson

By default, the returned credentials have read-only access to your registry
and cannot be used to push images. This is appropriate for most Kubernetes
clusters. To retrieve read/write credentials, suitable for use with the Docker
client or in a CI system, read_write may be provided as query parameter. For
example: /v2/registries/&#123;registry_name&#125;/docker-credentials?read_write=true

By default, the returned credentials will not expire. To retrieve credentials
with an expiry set, expiry_seconds may be provided as a query parameter. For
example: /v2/registries/&#123;registry_name&#125;/docker-credentials?expiry_seconds=3600 will return
credentials that expire after one hour.
registry_get_docker_credentials_legacyexecexpiry_seconds, read_writeIn order to access your container registry with the Docker client or from a
Kubernetes cluster, you will need to configure authentication. The necessary
JSON configuration can be retrieved by sending a GET request to
/v2/registry/docker-credentials.

The response will be in the format of a Docker config.json file. To use the
config in your Kubernetes cluster, create a Secret with:

kubectl create secret generic docr <br /> --from-file=.dockerconfigjson=config.json <br /> --type=kubernetes.io/dockerconfigjson

By default, the returned credentials have read-only access to your registry
and cannot be used to push images. This is appropriate for most Kubernetes
clusters. To retrieve read/write credentials, suitable for use with the Docker
client or in a CI system, read_write may be provided as query parameter. For
example: /v2/registry/docker-credentials?read_write=true

By default, the returned credentials will not expire. To retrieve credentials
with an expiry set, expiry_seconds may be provided as a query parameter. For
example: /v2/registry/docker-credentials?expiry_seconds=3600 will return
credentials that expire after one hour.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
registry_namestringThe name of a container registry. (example: example)
expiry_secondsintegerThe duration in seconds that the returned registry credentials will be valid. If not set or 0, the credentials will not expire. (example: 3600)
read_writebooleanBy default, the registry credentials allow for read-only access. Set this query parameter to true to obtain read-write credentials. (example: true)

SELECT examples

In order to access your container registry with the Docker client or from a
Kubernetes cluster, you will need to configure authentication. The necessary
JSON configuration can be retrieved by sending a GET request to
/v2/registries/&#123;registry_name&#125;/docker-credentials.

The response will be in the format of a Docker config.json file. To use the
config in your Kubernetes cluster, create a Secret with:

kubectl create secret generic docr <br /> --from-file=.dockerconfigjson=config.json <br /> --type=kubernetes.io/dockerconfigjson

By default, the returned credentials have read-only access to your registry
and cannot be used to push images. This is appropriate for most Kubernetes
clusters. To retrieve read/write credentials, suitable for use with the Docker
client or in a CI system, read_write may be provided as query parameter. For
example: /v2/registries/&#123;registry_name&#125;/docker-credentials?read_write=true

By default, the returned credentials will not expire. To retrieve credentials
with an expiry set, expiry_seconds may be provided as a query parameter. For
example: /v2/registries/&#123;registry_name&#125;/docker-credentials?expiry_seconds=3600 will return
credentials that expire after one hour.

SELECT
registry.digitalocean.com
FROM digitalocean.container_registry.docker_credentials
WHERE registry_name = '{{ registry_name }}' -- required;

Lifecycle Methods

In order to access your container registry with the Docker client or from a
Kubernetes cluster, you will need to configure authentication. The necessary
JSON configuration can be retrieved by sending a GET request to
/v2/registry/docker-credentials.

The response will be in the format of a Docker config.json file. To use the
config in your Kubernetes cluster, create a Secret with:

kubectl create secret generic docr <br /> --from-file=.dockerconfigjson=config.json <br /> --type=kubernetes.io/dockerconfigjson

By default, the returned credentials have read-only access to your registry
and cannot be used to push images. This is appropriate for most Kubernetes
clusters. To retrieve read/write credentials, suitable for use with the Docker
client or in a CI system, read_write may be provided as query parameter. For
example: /v2/registry/docker-credentials?read_write=true

By default, the returned credentials will not expire. To retrieve credentials
with an expiry set, expiry_seconds may be provided as a query parameter. For
example: /v2/registry/docker-credentials?expiry_seconds=3600 will return
credentials that expire after one hour.

EXEC digitalocean.container_registry.docker_credentials.registry_get_docker_credentials_legacy 
@expiry_seconds='{{ expiry_seconds }}',
@read_write={{ read_write }};