Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 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 an 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
    • Running the DeepSeek-R1 language model in a GPU cluster
    • Running a vLLM library with the Gemma 3 language model on a VM with GPU
    • Delivering USB devices to a virtual machine or BareMetal server
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Getting started
  • Create a VM from a Container Optimized Image with an additional volume for a Docker container
  1. Tutorials
  2. Container Optimized Image
  3. 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 an additional volume for a Docker container

Written by
Yandex Cloud
Updated at June 9, 2025
  • Getting started
  • Create a VM from a Container Optimized Image with an additional volume for a Docker container

In this tutorial, you will create a VM from a Container Optimized Image that contains a Docker container with a running MongoDB instance and an additional 10 GB volume attached.

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 from a Container Optimized Image with an additional volume for a Docker containerCreate a VM from a Container Optimized Image with an additional volume for a Docker container

CLI

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

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for creating a VM:

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

    version: '3.4'
    services:
      app2:
        container_name: container-name
        image: "mongo:latest"
        ports:
          - "27017:27017"
        restart: always
        volumes:
          - /home/yc-user/coi-data:/data
    x-yc-disks:
      - device_name: coi-data
        fs_type: ext4
        host_path: /home/yc-user/coi-data
    

    When creating a VM via the CLI, a default user is created: yc-user.

  3. Create a VM with multiple disks:

    yc compute instance create-with-container \
      --name coi-vm \
      --zone ru-central1-a \
      --create-boot-disk size=30 \
      --create-disk name=data-disk,size=10,device-name=coi-data \
      --network-interface subnet-name=<subnet_name>,nat-ip-version=ipv4 \
      --ssh-key <path_to_public_part_of_SSH_key> \
      --docker-compose-file docker-compose.yaml
    

    Where:

    • --name: VM name.

    • --zone: Availability zone.

    • --create-boot-disk: VM disk parameters.

      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: Network parameters:

      • subnet-name: Name of the subnet to host the VM.
      • nat-ip-version: Public IPv4 address assignment method.
    • --ssh-key: Path to the file with the public key.

    • --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. Get the ID of the running Docker container:

      sudo docker ps -a
      

      Result:

      CONTAINER ID  IMAGE         COMMAND                 CREATED        STATUS        PORTS      NAMES
      1f71********  mongo:latest  "docker-entrypoint.s…"  5 minutes ago  Up 5 minutes  27017/tcp  container-name
      
    3. Connect to the running Docker container:

      sudo docker exec -it 1f71******** bash
      
    4. View the list of attached disks. Pay attention to the mounted /dev/vdb 11G 24M 9.9G 1% /data disk:

      df -H
      

      Result:

      Filesystem  Size  Used  Avail  Use%  Mounted on
      overlay     32G   4.0G    27G   14%  /
      tmpfs       68M      0    68M    0%  /dev
      ...
      tmpfs       1.1G     0   1.1G    0%  /proc/acpi
      tmpfs       1.1G     0   1.1G    0%  /proc/scsi
      tmpfs       1.1G     0   1.1G    0%  /sys/firmware
      

For more information about working with VMs, see our step-by-step guides.

Was the article helpful?

Previous
Creating a VM from a Container Optimized Image
Next
Creating a VM from a Container Optimized Image with multiple Docker containers
© 2025 Direct Cursus Technology L.L.C.