Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Compute Cloud
  • Yandex Container Solution
    • All tutorials
    • Configuring time synchronization using NTP
    • Autoscaling an instance group to process messages from a queue
    • Updating an instance group under load
    • Deploying Remote Desktop Gateway
    • Getting started with Packer
    • Transferring logs from a VM to Yandex Cloud Logging
    • Building a VM image with infrastructure tools using Packer
    • Migrating data to Yandex Cloud using Hystax Acura
    • Fault protection with Hystax Acura
    • VM backups using Hystax Acura
    • Deploying a fault-tolerant architecture with preemptible VMs
    • Configuring a fault-tolerant architecture in Yandex Cloud
    • Creating a budget trigger that invokes a function to stop a VM
    • Creating triggers that invoke a function to stop a VM and send a Telegram notification
    • Creating a Python web application with Flask
    • Creating an SAP program in Yandex Cloud
    • Deploying a Minecraft server in Yandex Cloud
    • Automating image builds using Jenkins and Packer
    • Creating test VMs via GitLab CI
    • High-performance computing on preemptible VMs
    • Configuring an SFTP server based on CentOS 7
    • Deploying GlusterFS in high availability mode
    • Deploying GlusterFS in high performance mode
    • Backing up to Object Storage with Bacula
    • Building a CI/CD pipeline in GitLab using serverless products
    • Implementing a secure high-availability network infrastructure with a dedicated DMZ based on the Check Point NGFW
    • Cloud infrastructure segmentation with the Check Point next-generation firewall
    • Configuring a secure GRE tunnel over IPsec
    • Creating a bastion host
    • Implementing fault-tolerant scenarios for NAT VMs
    • Creating a tunnel between two subnets using OpenVPN Access Server
    • Creating an external table from a Object Storage bucket table using a configuration file
    • Setting up network connectivity between BareMetal and Virtual Private Cloud subnets
    • Working with snapshots in Managed Service for Kubernetes
      • Creating a VM from a Container Optimized Image
      • Creating a VM from a Container Optimized Image with an additional volume for a Docker container
      • Creating a VM from a Container Optimized Image with multiple Docker containers
      • Creating an instance group from a Container Optimized Image
      • Creating an instance group from a Container Optimized Image with multiple Docker containers
      • Updating a Container Optimized Image VM
      • Creating a VM and an instance group with a Container Optimized Image using Terraform
    • Launching the DeepSeek-R1 language model in a Yandex Compute Cloud GPU cluster
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Getting started
  • Set up your environment
  • Create an instance group from a Container Optimized Image with multiple Docker containers
  • Test the instance group based on the Container Optimized Image with multiple Docker containers
  1. Tutorials
  2. Container Optimized Image
  3. Creating an instance group from a Container Optimized Image with multiple Docker containers

Creating an instance group from a Container Optimized Image with multiple Docker containers

Written by
Yandex Cloud
Updated at May 5, 2025
  • Getting started
  • Set up your environment
  • Create an instance group from a Container Optimized Image with multiple Docker containers
  • Test the instance group based on the Container Optimized Image with multiple Docker containers

You can create an instance group based on a image Container Optimized Image with multiple Docker containers inside.

Docker containers are created based on the Docker Compose specification.

Alert

When creating instance groups, keep the limits in mind. Not to disrupt the component Instance Groups, do not update or delete manually created resources: target group Network Load Balancer, VMs, and disks. Instead of this, change or delete the entire group.

Getting startedGetting started

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

Set up your environmentSet up your environment

  1. Create a service account named group-coi and assign the editor role to it:

    Management console
    CLI
    API
    1. In the management console, select the folder where you want to create your service account.
    2. From the list of services, select Identity and Access Management.
    3. Click Create service account.
    4. Enter the name: group-coi.
    5. To assign the service account the editor role for the current folder, click Add role and select editor.
    6. Click Create.
    1. Create a service account:

      yc iam service-account create --name group-coi
      

      Result:

      id: ajeabccde01d********
      folder_id: b0g12ga82bcv********
      created_at: "2023-03-13T14:32:18.900092Z"
      name: group-coi
      
    2. Assign the role to the service account:

      yc resource-manager folder add-access-binding b0g12ga82bcv******** \
        --role editor \
        --subject serviceAccount:ajeabccde01d********
      

    Use the Create method for the ServiceAccount resource.

  2. Create a network named yc-auto-network and a subnet in the same availability zone:

    Management console
    CLI
    API
    1. In the management console, select the folder where you want to create your network.
    2. Select Virtual Private Cloud.
    3. Click Create network.
    4. Enter the network name: yc-auto-network.
    5. Select the additional option: Create subnets.
    6. Click Create network.
    1. Create a network:

      yc vpc network create --name yc-auto-network
      

      Result:

      id: enpabce123hd********
      folder_id: b0g12ga82bcv********
      created_at: "2023-03-13T14:57:15Z"
      name: yc-auto-network
      
    2. Create a subnet in the ru-central1-a availability zone:

      yc vpc subnet create --network-id enpabce123hd******** --range 192.168.1.0/24 --zone ru-central1-a
      

      Result:

      id: e1lnabc23r1c********
      folder_id: b0g12ga82bcv********
      created_at: "2023-03-13T16:23:12Z"
      network_id: enpabce123hd********
      zone_id: ru-central1-a
      v4_cidr_blocks:
      - 192.168.1.0/24
      
    1. Create a network using the Create method for the Networks resource.
    2. Create a subnet in the ru-central1-a availability zone using the Create method for the Subnets resource.

Create an instance group from a Container Optimized Image with multiple Docker containersCreate an instance group from a Container Optimized Image with multiple Docker containers

  1. Find out the ID of the latest version of the public Container Optimized Image.

    A Container Optimized Image in a Container Registry registry may be updated and changed with new releases. This will not automatically update the VM image to the latest version. To create an instance group with the latest Container Optimized Image version, you need to check whether it is available yourself:

    CLI
    Yandex Cloud Marketplace
    yc compute image get-latest-from-family container-optimized-image --folder-id standard-images
    

    Result:

    id: <ID_of_latest_COI_version>
    folder_id: standard-images
    ...
    
    1. Go to the Cloud Marketplace page and select the image with the configuration you need:
      • Container Optimized Image.
      • Container Optimized Image GPU.
    2. Under Product IDs, copy the value of image_id.
  2. Save the specification of the instance group with Container Optimized Image and multiple Docker containers to the specification.yaml file:

    name: group-coi-containers # VM group name, unique within the folder.
    service_account_id: ajeabccde01d******** # Service account ID.
    instance_template:
      service_account_id: ajeabccde01d******** # ID of the service account to access private Docker images.
      platform_id: standard-v3 # Platform ID.
      resources_spec:
        memory: 2G # Amount of memory (RAM).
        cores: 2 # Number of processor cores (vCPUs).
      boot_disk_spec:
        mode: READ_WRITE # Disk access mode (read and write).
        disk_spec:
          image_id: <latest_COI_version_ID>
          type_id: network-hdd # Disk type.
          size: 32G # Disk size. It must be at least 30 GB.
      network_interface_specs:
       - network_id: enpabce123hd******** # Network ID.
         subnet_ids:
           - e1lnabc23r1c******** # Subnet ID.
         primary_v4_address_spec: {
           one_to_one_nat_spec: {
             ip_version: IPV4 # IPv4 specification for public access to the VM.
           }
         }
      metadata: # Values to write to the VM metadata.
       docker-compose: |- # Key in the VM metadata that is used with the Docker Compose specification.
         version: '3.7'
         services:
           app1:
             container_name: nginx
             image: "nginx"
             ports:
               - "80:80"
             restart: always
           app2:
             container_name: redis
             image: "redis"
             restart: always
       ssh-keys: | # Parameter for providing an SSH key to the VM.
         yc-user:ssh-ed25519 ABC...d01 user@desktop.ru # Username for connecting to the VM.
    deploy_policy: # VM deployment policy for the group.
      max_unavailable: 1
      max_expansion: 0
    scale_policy: # Instance scaling policy for the group.
      fixed_scale:
        size: 2
    allocation_policy: # Instance allocation policy between availability zones.
      zones:
        - zone_id: ru-central1-a
    

    Note

    You can provide an SSH key in the VM metadata using the ssh-keys parameter or in the user-data key with the user metadata. This tutorial uses the first option.

  3. Create an instance group named group-coi-containers using the specification.yaml specification:

    CLI
    API

    Run this command:

    yc compute instance-group create --file=specification.yaml
    

    Result:

    done (48s)
    id: cl0q12abcd4e********
    folder_id: b0g12ga82bcv********
    ...
      target_size: "2"
    service_account_id: ajeabccde01d********
    status: ACTIVE
    

    Use the CreateFromYaml method for the InstanceGroup resource.

  4. Make sure the instance group from the Container Optimized Image and with multiple Docker containers was created:

    Management console
    CLI
    API
    1. In the management console, select the folder where you created the instance group.
    2. Select Compute Cloud.
    3. Navigate to Instance groups.
    4. Click the group-coi-containers instance group name.
    yc compute instance-group list-instances group-coi-containers
    

    Result:

    +----------------------+---------------------------+----------------------------------+-------------+------------------------+----------------+
    |     INSTANCE ID      |           NAME            |            EXTERNAL IP           | INTERNAL IP |         STATUS         | STATUS MESSAGE |
    +----------------------+---------------------------+----------------------------------+-------------+------------------------+----------------+
    | fhmabcv0de12******** | cl0q12abcs4g********-fmar | 84.201.155.117                   | 10.130.0.14 | RUNNING_ACTUAL [2h35m] |                |
    | fhmab0cdqj12******** | cl0q12abcs4g********-fqeg | 84.252.131.221                   | 10.130.0.47 | RUNNING_ACTUAL [2h35m] |                |
    +----------------------+---------------------------+----------------------------------+-------------+------------------------+----------------+
    

    View the list of created VM instances using the List method for the InstanceGroup resource.

Test the instance group based on the Container Optimized Image with multiple Docker containersTest the instance group based on the Container Optimized Image with multiple Docker containers

  1. Connect to one of the instances via SSH.

    CLI
    ssh yc-user@84.201.155.117
    

    Result:

    Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-54-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    Last login: Mon Mar 13 15:23:28 2023 from 123.456.789.101
    
  2. View a list of Docker containers running on the VM:

    CLI
    sudo docker ps -a
    

    Result:

    CONTAINER ID  IMAGE  COMMAND                 CREATED             STATUS             PORTS               NAMES
    c0a125a1765a  redis  "docker-entrypoint.s…"  About a minute ago  Up About a minute  6379/tcp            redis
    01288d7e382f  nginx  "/docker-entrypoint.…"  About a minute ago  Up About a minute  0.0.0.0:80->80/tcp  nginx
    

Was the article helpful?

Previous
Creating an instance group from a Container Optimized Image
Next
Updating a Container Optimized Image VM
© 2025 Direct Cursus Technology L.L.C.