Creating a registry
Any users and service accounts with folder access rights can use the created registry.
-
In the management console
, select the folder to create a registry in. -
In the list of services, select Container Registry.
-
Click Create registry.
-
Specify a name for the registry. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
(Optional) Add labels.
-
Click Create registry.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
Make sure that a registry has not been created in the folder yet:
yc container registry list
Result:
+----+------+-----------+ | ID | NAME | FOLDER ID | +----+------+-----------+ +----+------+-----------+
If the folder already contains a registry, see Updating a registry for information about how you can change it.
-
Create a registry:
yc container registry create --name my-reg
Result:
done id: crpd50616s9a******** folder_id: b1g88tflru0e******** name: my-reg status: ACTIVE created_at: "2019-01-09T14:34:06.601Z"
The registry naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
The
--name
flag is optional: you can create a registry without any name and access it using the ID. Thename
field is user-defined: it is used for listing in the YC CLI and is not used in the Docker CLI. -
Make sure the registry was created:
yc container registry list
Command result:
+----------------------+--------+----------------------+ | ID | NAME | FOLDER ID | +----------------------+--------+----------------------+ | crpd50616s9a******** | my-reg | b1g88tflru0e******** | +----------------------+--------+----------------------+
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
To a configuration file, add the parameters of the registry that you want to create. Use
example.tf
in~/cloud-terraform
:resource "yandex_container_registry" "my-reg" { name = "my-registry" folder_id = "<folder_ID>" labels = { my-label = "my-label-value" } }
Where:
name
: Registry namefolder_id
: Folder IDlabels
: Set of labels
For more information about resources you can create with Terraform, see the provider documentation
. -
Check that the configuration file is correct.
-
Use the command line to go to the directory where you saved the configuration file:
cd /Users/<username>/cloud-terraform
-
Run a check using this command:
terraform plan
Result:
Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. ... Note: You did not specify an "-out" parameter to save this plan, so Terraform cannot guarantee that exactly these actions will be performed if "terraform apply" is subsequently run.
-
-
Create a registry.
-
Run this command:
terraform apply
Result:
An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: + create ... Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value:
-
Confirm creation of the registry. To do this, type
yes
and press Enter:Enter a value: yes
Result:
yandex_container_registry.default: Creating... yandex_container_registry.default: Creation complete after 4s [id=crpuljdfqoj3********] Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
A registry named
my-registry
is created in the folder. -
Check the resources and their settings in the management console
.
-