Creating a VM from a custom image

Before getting started

Prepare and upload the image to create a VM from.

Make sure the uploaded image is in the READY status.

Create a VM from the prepared image

  1. Open the folder where the VM will be created.

  2. Click Create resource.

  3. Select Virtual machine.

  4. In the Name field, enter the VM name.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

    Note

    The virtual machine name is used for generating the FQDN, which cannot be changed later. If the FQDN is important to you, choose an appropriate name for the virtual machine at the creation stage. For more information about generating FQDN names, see the section Hostname and FQDN.

  5. Select the availability zone to locate the VM in.

  6. In the Disks section, click Add disk.

    1. In the Name field, enter the disk name.
    2. Set the required disk size.
    3. In Disk designation, choose Boot.
    4. Select the disk type: HDD or SSD.
    5. In Content, choose Image. A list of images that you uploaded opens.
    6. Select the necessary image.
    7. Click Add.
  7. In the Computing resources section:

    • Choose the platform.
    • Specify the necessary number of vCPUs and amount of RAM.
  8. In the Network settings section, click Add network.

  9. In the window that opens, select the subnet to connect the VM to when creating it.

  10. In Public address, choose:

    • Automatically — to set a public IP address automatically. The address is allocated from the pool of Yandex.Cloud addresses.
    • List — to select a public IP address from the list of static addresses. For more information, see the section Making a dynamic public IP address static in the Virtual Private Cloud service documentation.
    • No address — to not assign a public IP address.
  11. Specify data required for accessing the VM:

    • Enter the username in the Login field.
    • In the SSH key field, paste the contents of the public key file. You need to create a key pair for SSH connection yourself. To generate keys, use third-party tools, such as ssh-keygen utilities on Linux and macOS or PuTTygen on Windows.
  12. Click Create VM.

If you don't have the Yandex.Cloud command line interface yet, install 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 flag.

  1. See the description of the CLI's create VM command:

    $ yc compute instance create --help
    
  2. Get a list of images in the default folder:

    $ yc compute image list
    +----------------------+-------------------+--------+-------------+--------+
    |          ID          |       NAME        | FAMILY | PRODUCT IDS | STATUS |
    +----------------------+-------------------+--------+-------------+--------+
    |         ...          |         ...       |        |             |  ...   |
    | fd8gkcd3l6ov84aon8s1 |  your-test-image  |        |             | READY  |
    |         ...          |         ...       |        |             |  ...   |
    +----------------------+-------------------+--------+-------------+--------+
    
  3. Select the ID or NAME of the image you need.

  4. Create a VM in the default folder:

    $ yc compute instance create \
      --name test-vm-from-image \
      --zone ru-central1-a \
      --create-boot-disk name=disk1,size=5,image-id=fd8gkcd3l6ov84aon8s1 \
      --public-ip \
      --ssh-key ~/.ssh/id_rsa.pub
    

    This command creates a VM with a 5 GB boot disk from the pre-loaded image named test-vm-from-image.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

    Note

    The virtual machine name is used for generating the FQDN, which cannot be changed later. If the FQDN is important to you, choose an appropriate name for the virtual machine at the creation stage. For more information about generating FQDN names, see the section Hostname and FQDN.

    The yc-user user will be created on the VM with a public key from the ~/.ssh/id_rsa.pub file. The VM gets a public IP address. To create a VM without a public IP, remove the --public-ip flag.

Use the Create method for the Instance resource.