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. -
Select Serverless Containers.
-
Select the container whose revision you want to create.
-
Go to the Editor tab.
-
Under Image settings, you can additionally specify revision parameters:
-
Command: Commands that the container will run when started. It matches the
ENTRYPOINT
instruction in the Dockerfile. -
Arguments: Matches the
CMD
instruction in the Dockerfile. Specify arguments inkey = value
format. If you do not specify this parameter, the defaultCMD
value 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 a container. It matches the
WORKDIR
instruction in the Dockerfile. We recommend setting absolute paths to folders.
-
-
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 \
--concurrency 1 \
--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. -
--concurrency
: Maximum number of concurrent requests to a single container instance. May be in the range between 1 (default) and 16. If the number of requests to a container exceeds theconcurrency
value, Serverless Containers scales the container up by running its additional instances.Note
The number of container instances and concurrent container requests in each zone cannot exceed the quota.
-
--execution-timeout
: Timeout. The default value is 3 seconds. -
--service-account-id
: ID of the service account with permissions to download a Docker image. -
--command
: Commands the container will run when started. Separate them by commas. It matches theENTRYPOINT
instruction in the Dockerfile. -
--args
: Arguments matching theCMD
instruction in the Dockerfile. Specify them inkey = value
format separated by commas. If you do not specify this parameter, the defaultCMD
value 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 documentation on the Terraform
If you don't have Terraform, install it and configure the Yandex Cloud provider.
In Terraform, a new revision is created every time the resource runtime parameters are updated.
To create a revision:
-
Update the parameters of the
yandex_serverless_container
resource in the configuration file:resource "yandex_serverless_container" "test-container" { name = "<container_name>" cores = "<number_of_cores>" memory = "<memory_size>" concurrency = "<concurrent_requests>" 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. -
concurrency
: Maximum number of concurrent requests to a single container instance. May be in the range between 1 (default) and 16. If the number of requests to a container exceeds theconcurrency
value, Serverless Containers scales the container up by running its additional instances.Note
The number of container instances and concurrent container requests in each zone cannot exceed the quota.
-
command
: Commands the container will run when started. Separate them by commas. It matches theENTRYPOINT
instruction in the Dockerfile. -
args
: Arguments matching theCMD
instruction in the Dockerfile. Specify them inkey = value
format separated by commas. If you do not specify this parameter, the default CMD value from the Docker image will be used. -
work_dir
: Allows you to change the working directory of a container. It matches theWORKDIR
instruction in the Dockerfile. We recommend setting absolute paths to folders.
For more information about the yandex_serverless_container
resource parameters in Terraform, see the relevant provider documentation
-
Create resources:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
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.