Configuring access to a registry
You can set up policies for accessing a registry from specific IP addresses.
- In the management console
, select the folder containing the registry. - Navigate
to Container Registry. - Select the registry to configure access to.
- In the left-hand panel, click
Access for IP address. - Click Set.
- Enter the IP address and specify the action:
PULLto allow pulling Docker images from the registry, orPUSHto allow pushing them to the registry. - To configure access for multiple IP addresses, click Add.
- Click Save.
-
View the list of available registries, their names and IDs:
yc container registry listResult:
+----------------------+--------+----------------------+ | ID | NAME | FOLDER ID | +----------------------+--------+----------------------+ | crpd50616s9a******** | my-reg | b1g88tflru0e******** | +----------------------+--------+----------------------+ -
Specify registry access settings:
yc container registry set-ip-permissions <registry_name> \ --pull <IP_address> \ --push <IP_address>Where:
--pull: Flag that allows pulling Docker images from the registry.--push: Flag that allows pushing Docker images to the registry.
To learn more about the command, see the CLI reference.
Running this command will remove all existing IP address permissions. To continue, type
yesand press Enter.Result:
WARN: All current ip permissions will be deleted. Are you sure?[y/N] -
Check the applied restrictions:
yc container registry list-ip-permissions <registry_name>Result:
+--------+-----------+ | ACTION | IP | +--------+-----------+ | PULL | 10.1.2.11 | | PUSH | 10.1.2.11 | +--------+-----------+
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the guides on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.
-
Specify registry access settings in the Terraform configuration file.
resource "yandex_container_registry_ip_permission" "my_ip_permission" { registry_id = <registry_ID> push = [ "<IP_address>", "<IP_address>" ] pull = [ "<IP_address>", "<IP_address>" ] }Where:
my_registry: Registry ID. If the configuration already contains the yandex_container_registry resource, you can specify it, e.g.,yandex_container_registry.my_registry.id.pull: IP addresses that are allowed to pull Docker images from the registry. This is an optional setting.push: IP addresses that are allowed to push Docker images to the registry. This is an optional setting.
For more information about the
yandex_container_registry_ip_permissionproperties in Terraform, see this provider guide. -
Create the resources:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check the new resources using the management console
or this CLI command:yc container registry list-ip-permissions <registry_name> -