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
  • Create a VM with multiple Docker containers
  1. Tutorials
  2. Container Optimized Image
  3. Creating a VM from a Container Optimized Image with multiple Docker containers

Creating a VM from a Container Optimized Image with multiple Docker containers

Written by
Yandex Cloud
Updated at May 5, 2025
  • Getting started
  • Create a VM with multiple Docker containers

In this tutorial, you will create a VM with multiple Docker containers from a Container Optimized Image image. A VM is created based on the Docker Compose specification.

Getting startedGetting started

If the required Docker image is pushed to Yandex Container Registry, create a service account with the container-registry.images.puller role for the registry in use. A Container Optimized Image VM will pull the Docker image from the registry on behalf of this account.

Create a VM with multiple Docker containersCreate a VM with multiple Docker containers

CLI

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.

To create a VM with multiple Docker containers from a Container Optimized Image:

  1. View the description of the CLI command to create a VM from a Container Optimized Image:

    yc compute instance create-with-container --help
    
  2. Create a Docker container specification. Save the following data to the docker-compose.yaml file:

    version: '3.7'
    services:
      app1:
        container_name: nginx
        image: "nginx"
        ports:
          - "80:80"
        restart: always
      app2:
        container_name: redis
        image: "redis"
        restart: always
    
  3. Create a VM with multiple Docker containers:

    yc compute instance create-with-container \
      --name my-vm \
      --zone ru-central1-a \
      --ssh-key ssh-key.pub \
      --create-boot-disk size=30 \
      --network-interface subnet-name=<subnet_name>,nat-ip-version=ipv4 \
      --service-account-name default-sa \
      --docker-compose-file docker-compose.yaml
    

    Where:

    • --name: VM name.

    • --zone: Availability zone.

    • --ssh-key: Path to the public key file and its name.

    • --create-boot-disk size: Boot disk size.

      To get the minimum boot disk size required for installing an image, run this command:

      • yc compute image get-latest-from-family container-optimized-image --folder-id standard-images if you are installing a Container Optimized Image.
      • yc compute image get-latest-from-family container-optimized-image-gpu --folder-id standard-images if you are installing a GPU Container Optimized Image.

      You can find the minimum boot disk size in the min_disk_size property.

    • --network-interface: VM network settings.

    • --service-account-name: Service account name.

    • --docker-compose-file: YAML file with container specification.

    Once created, the VM will appear in the VM list under Compute Cloud in the management console.

  4. Check the result.

    1. Connect to the VM via SSH.

    2. View a list of running Docker containers:

      sudo docker ps -a
      

      Result:

      CONTAINER ID  IMAGE  COMMAND                 CREATED         STATUS         PORTS               NAMES
      c79b********  nginx  "nginx -g 'daemon of…"  16 seconds ago  Up 14 seconds  0.0.0.0:80->80/tcp  nginx
      3ac5********  redis  "docker-entrypoint.s…"  2 minutes ago   Up 2 minutes   6379/tcp            redis
      

Was the article helpful?

Previous
Creating a VM from a Container Optimized Image with an additional volume for a Docker container
Next
Creating an instance group from a Container Optimized Image
© 2025 Direct Cursus Technology L.L.C.