Learn R Programming

AzureContainers (version 1.0.2)

docker_registry: Docker registry class

Description

Class representing a Docker registry. Note that this class can be used to interface with any Docker registry that supports the HTTP V2 API, not just those created via the Azure Container Registry service.

Usage

docker_registry

Arguments

Format

An object of class R6ClassGenerator of length 24.

Methods

The following methods are available, in addition to those provided by the AzureRMR::az_resource class:

  • new(...): Initialize a new registry object. See 'Details'.

  • login: Login to the registry via docker login.

  • push(src_image, dest_image): Push an image to the registry, using docker tag and docker push.

  • pull(image): Pulls an image from the registry, using docker pull.

  • delete_layer(layer, digest, confirm=TRUE): Deletes a layer from the registry.

  • delete_image(image, digest, confirm=TRUE): Deletes an image from the registry.

  • list_repositories: Lists the repositories (images) in the registry.

Details

The arguments to the new() method are:

  • server: The name of the registry server.

  • username: The username that Docker will use to authenticate with the registry.

  • password: The password that Docker will use to authenticate with the registry.

  • login: Whether to login to the registry immediately; defaults to TRUE.

Currently this class does not support authentication methods other than a username/password combination.

The login(), push() and pull() methods for this class call the docker commandline tool under the hood. This allows all the features supported by Docker to be available immediately, with a minimum of effort. Any calls to the docker tool will also contain the full commandline as the cmdline attribute of the (invisible) returned value; this allows scripts to be developed that can be run outside R.

See Also

acr, call_docker

Docker commandline reference

Docker registry API

Examples

Run this code
# NOT RUN {
# recommended way of retrieving a registry: via a resource group object
rg <- AzureRMR::az_rm$
    new(tenant="myaadtenant.onmicrosoft.com", app="app_id", password="password")$
    get_subscription("subscription_id")$
    get_resource_group("rgname")

# get the registry endpoint
dockerreg <- rg$get_acr("myregistry")$get_docker_registry()

dockerreg$login()
dockerreg$list_repositories()

# create an image from a Dockerfile in the current directory
call_docker("build -t myimage .")

# push the image
dockerreg$push("myimage")

# }

Run the code above in your browser using DataLab