Creating a container revision
You need to create a new revision:
- When you upload a new Docker image version to Yandex Container Registry.
- When you modify revision settings.
Note
To ensure the integrity of version links, you cannot update or delete container revisions.
If a registry or repository containing the Docker image is not public, you need to specify a service account with permission to download the Docker image in the revision settings. For example, the container-registry.images.puller role to the folder or registry containing the Docker image.
If a service account is specified in the revision settings, the user or the service account creating the revision must have the iam.serviceAccounts.user role. It confirms the right to use the service account.
-
In the management console
, select the folder with your container. -
Navigate to Serverless Containers.
-
Select the container whose revision you want to create.
-
Navigate to the Editor tab.
-
Under Image settings:
- Specify the Yandex Container Registry Docker image URL.
- Additionally specify the revision settings as required:
-
Command: Commands the container will run when started. It matches the
ENTRYPOINTinstruction in the Dockerfile. -
Arguments: Matches the
CMDinstruction in the Dockerfile. Specify arguments inkey = valueformat. If you do not specify this parameter, the defaultCMDvalue from the Docker image will be used.You can provide multiple arguments to a container. To do this, click Add.
-
Working directory: Allows you to change the working directory of the container. It matches the
WORKDIRinstruction in the Dockerfile. We recommend setting absolute paths to directories.
-
-
Click Create revision.
To create a container revision, run this command:
yc serverless container revision deploy \
--container-name <container_name> \
--image <Docker_image_URL> \
--cores 1 \
--memory 1GB \
--execution-timeout 30s \
--service-account-id <service_account_ID> \
--command '<command_1>','<command_2>' \
--args '<key_1=value_1>','<key_2=value_2>'
Where:
--cores: Number of cores available to the container.--memory: Required memory. The default value is 128 MB.--execution-timeout: Timeout. The default value is 3 seconds.--service-account-id: ID of the service account with Docker image pull permissions.--command: Commands the container will run when started. Separate them by commas. It matches theENTRYPOINTinstruction in the Dockerfile.--args: Arguments matching theCMDinstruction in the Dockerfile. Specify them inkey = valueformat separated by commas. If you skip this setting, the defaultCMDvalue from the Docker image will be used.
Result:
id: bbajn5q2d74c********
container_id: bba3fva6ka5g********
created_at: "2021-07-09T15:04:55.135Z"
image:
image_url: cr.yandex/crpd3cicopk7********/test-container:latest
image_digest: sha256:de8e1dce7ceceeafaae122f7670084a1119c961cd9ea1795eae92bd********
resources:
memory: "1073741824"
cores: "1"
execution_timeout: 3s
service_account_id: ajeqnasj95o7********
status: ACTIVE
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation 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.
In Terraform, each update to the resource settings creates a new revision.
To create a revision:
-
Update the
yandex_serverless_containerresource settings in the configuration file:resource "yandex_serverless_container" "test-container" { name = "<container_name>" cores = "<number_of_cores>" memory = "<memory_size>" service_account_id = "<service_account_ID>" image { url = "<Docker_image_URL>" command = ["<command_1>","<command_2>"] args = ["<key_1=value_1>","key_2=value_2"] work_dir = "<working_directory>" } }Where:
cores: Number of cores available to the container.memory: Required memory. The default value is 128 MB.command: Commands the container will run when started. Separate them by commas. It matches theENTRYPOINTinstruction in the Dockerfile.args: Arguments matching theCMDinstruction in the Dockerfile. Specify them inkey = valueformat separated by commas. If you skip this setting, the default CMD value from the Docker image will be used.work_dir: Allows you to change the working directory of the container. It matches theWORKDIRinstruction in the Dockerfile. We recommend setting absolute paths to directories.
For more information about
yandex_serverless_containerproperties 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.
This will create the revision. You can check the new revision using the management console
or this CLI command:yc serverless container revision list -
To create a container revision, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.