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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
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 a Docker container from a Container Optimized Image
  1. Tutorials
  2. Container Optimized Image
  3. Creating a VM from a Container Optimized Image

Creating a VM from a Container Optimized Image

Written by
Yandex Cloud
Improved by
Danila N.
Updated at May 5, 2025
  • Getting started
  • Create a VM with a Docker container from a Container Optimized Image

Create a VM from a Container Optimized Image and run a Docker container on it.

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 a Docker container from a Container Optimized ImageCreate a VM with a Docker container from a Container Optimized Image

Management console
CLI using flags
CLI using a specification file
  1. In the management console, select the folder to create your VM in.

  2. In the list of services, select Compute Cloud.

  3. In the left-hand panel, select Virtual machines.

  4. Click Create virtual machine.

  5. Under Boot disk image, navigate to the Container Solution tab.

  6. Click Configure.

  7. In the Docker container settings window that opens, set the parameters using suggestions:

    • (Optional) Enter the Name of the Docker container to run on the VM. The naming requirements are as follows:

      • It must be from 2 to 63 characters long.
      • It may contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    • Specify the Docker image to be used to run the Docker container on the VM. You can do this in one of the following ways:

      • By selecting one of the available images. To do this, start typing the image name in the search bar. The image search reads all the available cloud folders.
      • By specifying the image name manually. To do this, click Enter link and enter the image name. You can specify an image from Container Registry or any publicly available Docker image library (such as Docker Hub).
    • (Optional) In the Command field, specify the executable file to run when the Docker container starts.

    • (Optional) Set Command arguments.

    • (Optional) Specify Environment variables you want to make available in the Docker container in key:value format.

    • Select the Restart policy field value for the Docker container:

      • Always: Always restart the Docker container when it stops.
      • On-Failure: Restart the Docker container only if it shuts down with a non-zero return code.
      • Never: Do not restart the Docker container automatically.
    • (Optional) Enable Attach a TTY to the Docker container to use the command shell in the Docker container.

    • (Optional) Enable Allocate an stdin buffer for a running Docker container to link the input stream to the running Docker container.

    • (Optional) Enable Run Docker container in privileged mode to allow the Docker container processes to access all VM resources.

  8. Click Apply.

  9. Use this guide to configure the remaining VM parameters.

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 and set Docker container parameters via the YC CLI:

  1. View a description of the command:

    yc compute instance create-with-container --help
    
  2. Run this command:

    yc compute instance create-with-container \
      --name my-vm \
      --zone ru-central1-b \
      --ssh-key ssh-key.pub \
      --service-account-name my-robot \
      --create-boot-disk size=30 \
      --public-ip \
      --platform standard-v3 \
      --container-name=my-app \
      --container-image=cr.yandex/mirror/ubuntu:20.04 \
      --container-command=sleep \
      --container-arg="1000" \
      --container-env=KEY1=VAL1,KEY2=VAL2 \
      --container-privileged
    

    Where:

    • --name: VM name.

    • --zone: Availability zone.

    • --ssh-key: Contents of the public key file.

    • --service-account-name: Service account 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.

    • --public-ip: Public IP address allocated to the VM.

    • --container-name: Docker container name.

    • --container-image: Name of the Docker image used to run the Docker container.

    • --container-command: Command to run when you start the Docker container.

    • --container-arg: Parameters for the command specified in --container-command.

    • --container-env: Environment variables available in the Docker container.

    • --container-privileged: Run the Docker container in privileged mode.

    Result:

    done (17s)
     id: epdbf646ge5q********
     folder_id: b1g88tflru0e********
     created_at: "2023-03-13T09:44:03Z"
     name: my-vm
    ...
    

Once created, the VM will appear in the VM list under Compute Cloud in the management console. For more information about working with VMs, see our step-by-step guides.

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 and set Docker container parameters using a specification file:

  1. View a description of the command:

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

    spec:
      containers:
      - command:
        - sleep
        args:
        - 100000
        image: cr.yandex/mirror/ubuntu:20.04
        name: my-container
        securityContext:
         privileged: true
    
  3. Run this command:

    yc compute instance create-with-container \
      --coi-spec-file docker-spec.yaml \
      --name my-vm \
      --zone ru-central1-b \
      --ssh-key ssh-key.pub \
      --create-boot-disk size=30 \
      --service-account-name my-service-account \
      --public-ip
    

    Where:

    • --coi-spec-file: Path to the Docker container specification file.

    • --name: VM name.

    • --zone: Availability zone.

    • --ssh-key: Contents of the public key file.

    • --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.

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

    • --public-ip: Public IP address allocated to the VM.

    Result:

    done (1m40s)
     id: epde18u4mahl********
     folder_id: b1g7gvsi89m3********
     created_at: "2023-03-13T13:50:17Z"
     name: my-vm
     ...
    

Once created, the VM will appear in the VM list under Compute Cloud in the management console. For more information about working with VMs, see our step-by-step guides.

Was the article helpful?

Previous
Working with snapshots in Managed Service for Kubernetes
Next
Creating a VM from a Container Optimized Image with an additional volume for a Docker container
Yandex project
© 2025 Yandex.Cloud LLC