Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Serverless Containers
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Getting an IAM token for a service account using a container
    • Getting information about a container
    • Managing rights to access a container
    • Creating a container
      • Creating a container
      • Creating a container revision
    • Invoking a container
    • Managing a container
    • Getting information about a trigger
    • Creating a trigger
    • Managing triggers
  • Concepts
  • Practical guidelines
  • Access management
  • Pricing policy
  • Containers API reference
  • API Triggers reference
  • Questions and answers
  1. Step-by-step instructions
  2. Creating a container
  3. Creating a container

Creating a container

Written by
Yandex Cloud
    Management console
    CLI
    API
    Terraform
    1. In the management console, select the folder where you wish to create your container.

    2. Select Serverless Containers.

    3. Click Create container.

    4. Enter a name and a description for the container. Name format:

      • The length can be from 3 to 63 characters.
      • It may contain lowercase Latin letters, numbers, and hyphens.
      • The first character must be a letter. The last character can't be a hyphen.
    5. Click Create.

    If you don't 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.

    To create a container, run the command:

    yc serverless container create --name <container_name>
    

    Result:

    id: bba3fva6ka5g********
    folder_id: b1gqvft7kjk3********
    created_at: "2021-07-09T14:49:00.891Z"
    name: my-beta-container
    url: https://bba3fva6ka5g********.containers.yandexcloud.net/
    status: ACTIVE
    

    You can create a container using the API create method.

    With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it by configuration files. They store the infrastructure description in HashiCorp Configuration Language (HCL). Terraform and its providers are distributed under the Mozilla Public License.

    For more information about the provider resources, see the documentation on the Terraform site or mirror site.

    If you change the configuration files, Terraform automatically determines which part of your configuration is already deployed and what should be added or removed.

    If you don't have Terraform, install it and configure the Yandex Cloud provider.

    To create a container and a container revision:

    Note

    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.

    1. In the configuration file, describe the parameters of resources that you want to create:

      • name is the container name. Required parameter. Naming requirements:

        • The length can be from 3 to 63 characters.
        • It may contain lowercase Latin letters, numbers, and hyphens.
        • The first character must be a letter. The last character can't be a hyphen.
      • memory: Amount of memory allocated to a container, MB. The default is 128 MB.

      • service_account_id = service account ID.

      • url: Docker image URL in Container Registry.

      Example configuration file structure:

      provider "yandex" {
        token     = "<OAuth>"
        cloud_id  = "<cloud ID>"
        folder_id = "<folder ID>"
        zone      = "ru-central1-a"
      }
      
      resource "yandex_serverless_container" "test-container" {
         name               = "<container name>"
         memory             = <memory size>
         service_account_id = "<service account ID>"
         image {
             url = "<Docker image URL>"
         }
      }
      

      For more information about the yandex_serverless_container resource in Terraform, see the provider documentation.

    2. Make sure that the configuration files are valid.

      1. In the command line, go to the directory where you created the configuration file.

      2. Run the check using the command:

        terraform plan
        

      If the configuration is described correctly, the terminal displays a list of created resources and their parameters. If the configuration contains errors, Terraform will point them out.

    3. Deploy the cloud resources.

      1. If the configuration doesn't contain any errors, run the command:

        terraform apply
        
      2. Confirm the resource creation: type yes in the terminal and press Enter.

      Afterwards, all the necessary resources are created in the specified folder. You can verify that the resources are there and properly configured in the management console or using the following CLI command:

      yc serverless container list
      

    Was the article helpful?

    Language / Region
    Yandex project
    © 2023 Yandex.Cloud LLC