Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 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
    • 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
    • Running a Docker image on a VM using Cloud Registry
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Get your cloud ready
  • Required paid resources
  • Create an SSH key pair
  • Install and configure Docker
  • Create a registry in Cloud Registry
  • Create a service account
  • Create an authorized key for the service account
  • Create a cloud network and subnet
  • Create a VM
  • Build a Docker image and push it to Cloud Registry
  • Push the Docker image to the VM
  • How to delete the resources you created
  1. Tutorials
  2. Running a Docker image on a VM using Cloud Registry

Running a Docker image on a VM using Yandex Cloud Registry

Written by
Yandex Cloud
Updated at January 13, 2026
  • Get your cloud ready
    • Required paid resources
    • Create an SSH key pair
    • Install and configure Docker
  • Create a registry in Cloud Registry
  • Create a service account
  • Create an authorized key for the service account
  • Create a cloud network and subnet
  • Create a VM
  • Build a Docker image and push it to Cloud Registry
  • Push the Docker image to the VM
  • How to delete the resources you created

In this tutorial, you will deploy a Docker image from a registry in Yandex Cloud Registry and run a container on a Yandex Compute Cloud VM instance.

To run a Docker image on a VM:

  1. Get your cloud ready.
  2. Create a Cloud Registry.
  3. Create a service account.
  4. Create an authorized key for the service account.
  5. Create a cloud network with a subnet.
  6. Create a VM.
  7. Build a Docker image and push it to Cloud Registry.
  8. Push the Docker image to the VM.

If you no longer need the resources you created, delete them.

Get your cloud readyGet your cloud ready

Sign up for Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or create a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure.

Learn more about clouds and folders here.

Required paid resourcesRequired paid resources

The cost of resources for running a Docker image includes:

  • Fee for a continuously running VM (see Yandex Compute Cloud pricing).
  • Fee for storing created images (see Yandex Cloud Registry pricing).
  • Fee for outbound traffic from Yandex Cloud to the internet (see Yandex Compute Cloud pricing).

Create an SSH key pairCreate an SSH key pair

Prepare an SSH key for VM access.

Linux/macOS
Windows 10/11
Windows 7/8
  1. Open the terminal.

  2. Use the ssh-keygen command to create a new key:

    ssh-keygen -t ed25519 -C "<optional_comment>"
    

    You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

    After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

    By default, the command prompts you to save the key under the id_ed25519 name in the following directory: /home/<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

If you do not have OpenSSH installed yet, follow this guide to install it.

  1. Run cmd.exe or powershell.exe (make sure to update PowerShell before doing so).

  2. Use the ssh-keygen command to create a new key:

    ssh-keygen -t ed25519 -C "<optional_comment>"
    

    You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

    After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

    By default, the command prompts you to save the key under the id_ed25519 name in the following folder: C:\Users\<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

Create keys using the PuTTY app:

  1. Download and install PuTTY.

  2. Add the folder with PuTTY to the PATH variable:

    1. Click Start and type Change system environment variables in the Windows search bar.
    2. Click Environment Variables... at the bottom right.
    3. In the window that opens, find the PATH parameter and click Edit.
    4. Add your folder path to the list.
    5. Click OK.
  3. Launch the PuTTYgen app.

  4. Select EdDSA as the pair type to generate. Click Generate and move the cursor in the field above it until key creation is complete.

    ssh_generate_key

  5. In Key passphrase, enter a strong password. Enter it again in the field below.

  6. Click Save private key and save the private key. Do not share its key phrase with anyone.

  7. Click Save public key and save the public key to a file named <key_name>.pub.

Warning

Store your private key securely, as you will not be able to connect to the VM without it.

Install and configure DockerInstall and configure Docker

Linux
macOS
Windows
  1. Install Docker Engine. Use this guide to install and run Docker for your operating system.

  2. After the installation is complete, add the current user to the docker group:

    sudo groupadd docker
    sudo usermod -aG docker $USER
    newgrp docker
    

For groups to update successfully, you may need to log back into the OS or reboot the computer.

For information about additional Docker settings for Linux, see the developer documentation.

If you are working on a device with a GUI, you can also install Docker Desktop for Linux.

Download and install the Docker Desktop distribution for macOS. For more information, see the developer documentation.

  1. Download and install the Docker Desktop distribution for Windows.

  2. After the installation is complete, add the current user to the docker-users group:

    1. Run Computer Management as administrator:

      compmgmt.msc
      
    2. Expand the (Local) Computer Management menu, then go Utilities → Local Users and Groups → Groups and open the docker-users group.

    3. Click Add and add the required user to the group.

    4. Click OK.

  3. Run Docker Desktop and make sure the app's status is running.

For information about additional Docker settings for Windows, see the developer documentation.

Create a registry in Cloud RegistryCreate a registry in Cloud Registry

Create a registry for storing Docker images.

Management console
CLI
API
  1. In the management console, select the folder you want to create a registry in.

  2. Go to Cloud Registry.

  3. Click Create registry.

  4. Select Docker for the format.

  5. Set the registry type to Local.

  6. Enter a name for the registry. Follow these naming requirements:

    • It must be from 3 to 62 characters long.
    • It can only contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.
  7. Click Create.

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 registry:

    yc cloud-registry registry create --help
    
  2. Create a registry:

    yc cloud-registry registry create \
      --name docker-ycr \
      --description "Created with CLI" \
      --registry-kind docker \
      --registry-type local
    

    Result:

    id: cn191rncdrhd********
    folder_id: b1g681qpemb4********
    name: docker-ycr
    kind: DOCKER
    type: LOCAL
    status: ACTIVE
    description: Created with CLI
    created_at: "2025-12-12T04:56:32.681439Z"
    modified_at: "2025-12-12T04:56:34.171714Z"
    

Use the create REST API method for the Registry resource or the RegistryService/Create gRPC API call.

Create a service accountCreate a service account

Create a service account you will use to pull the Docker image to the VM. Assign it the cloud-registry.artifacts.puller role for the created registry.

Management console
CLI
API
  1. Go to Identity and Access Management.
  2. At the top of the screen, navigate to the Service accounts tab.
  3. Click Create service account.
  4. Specify the service account name: docker-puller.
  5. Click Create.
  6. Go to Cloud Registry.
  7. Select the previously created registry.
  8. Navigate to the Access bindings tab.
  9. Click Assign roles.
  10. In the window that opens, select the docker-puller service account.
  11. Click Add role and select cloud-registry.artifacts.puller.
  12. Click Save.
  1. Create a service account:

    yc iam service-account create --name docker-puller
    

    Result:

    id: ajelabcde12f********
    folder_id: b0g12ga82bcv********
    created_at: "2020-11-30T14:32:18.900092Z"
    name: docker-puller
    
  2. Assign the cloud-registry.artifacts.puller role to the service account:

    yc cloud-registry registry add-access-binding <registry_name_or_ID> \
      --role cloud-registry.artifacts.puller \
      --subject serviceAccount:<service_account_ID>
    

    Where --subject is the docker-puller service account ID.

    Result:

    ...1s...done (5s)
    
  1. To create a service account, use the create REST API method for the ServiceAccount resource.
  2. To assign the service account a role for the registry, use the updateAccessBindings REST API method for the Registry resource.

Create an authorized key for the service accountCreate an authorized key for the service account

Create an authorized key for the docker-puller service account An authorized key will allow the service account to get an IAM token for authentication in the Yandex Cloud API.

Management console
CLI
API
  1. Go to Identity and Access Management.
  2. In the list that opens, select docker-puller.
  3. In the top panel, click Create new key and select Create authorized key.
  4. Click Create.
  5. In the window that opens, click Download file with keys and then Close

The action will download to your computer a file named authorized_key.json containing the authorized key. You will need this key later to set up Docker on your VM.

Run this command:

yc iam key create \
  --service-account-name docker-puller \
  -o authorized_key.json

Result:

id: ajetn5b1efv2********
service_account_id: ajefbp899mcl********
created_at: "2025-12-17T04:57:16.241850455Z"
key_algorithm: RSA_2048

The action will download to your computer a file named authorized_key.json containing the authorized key. You will need this key later to set up Docker on your VM.

Use the create REST API method for the Key resource or the KeyService/Create gRPC API call.

Create a cloud network and subnetCreate a cloud network and subnet

Create a cloud network with a subnet to host the VM.

Management console
CLI
API
  1. Go to Virtual Private Cloud.
  2. Click Create network.
  3. In the Name field, specify docker-ycr-network.
  4. In the Advanced field, disable Create subnets.
  5. Click Create network.
  6. Select vipnet-network.
  7. Click Create subnet at the top right.
  8. In the Name field, specify docker-ycr-subnet-ru-central1-b.
  9. In the Availability zone field, select ru-central1-b.
  10. In the CIDR field, specify 192.168.1.0/24.
  11. Click Create subnet.
  1. Create a cloud network named docker-ycr-network:

    yc vpc network create docker-ycr-network
    

    Result:

    id: enp1gg8kr3pv********
    folder_id: b1gt6g8ht345********
    created_at: "2023-12-20T20:08:11Z"
    name: docker-ycr-network
    default_security_group_id: enppne4l2eg5********
    

    For more information about the yc vpc network create command, see the CLI reference.

  2. Create a subnet in the ru-central1-b availability zone:

    yc vpc subnet create docker-ycr-subnet-ru-central1-b \
      --zone ru-central1-b \
      --network-name docker-ycr-network \
      --range 192.168.1.0/24
    

    Result:

    id: e2li9tcgi7ii********
    folder_id: b1gt6g8ht345********
    created_at: "2023-12-20T20:11:16Z"
    name: docker-ycr-subnet-ru-central1-b
    network_id: enp1gg8kr3pv********
    zone_id: ru-central1-b
    v4_cidr_blocks:
      - 192.168.1.0/24
    

    For more information about the yc vpc subnet create command, see the CLI reference.

  1. To create a cloud network, use the create REST API method or the NetworkService/Create gRPC API call.
  2. To create a subnet, use the create REST API method or the SubnetService/Create gRPC API call.

Create a VMCreate a VM

Create a VM with a public IP address and associate it with the service account you created.

Management console
CLI
API
  1. Go to Compute Cloud.

  2. Click Create virtual machine.

  3. Under Boot disk image, select an image and a Linux-based OS version.

  4. Under Location, select an availability zone for your VM.

  5. Under Network settings:

    • In the Subnet field, select the previously created network and subnet.
    • In the Public IP address field, leave the Auto value to assign a random external IP address from the Yandex Cloud pool.
  6. Under Access, specify the VM access credentials:

    • In the Login field, enter the username.
    • In the SSH key field, paste the contents of the public key file.
  7. Under General information, specify the VM name: docker-vm.

  8. Under Additional, select the docker-puller service account you created earlier.

  9. Click Create VM.

Create a VM in the default folder:

yc compute instance create \
  --name docker-vm \
  --zone ru-central1-b \
  --network-interface subnet-name=docker-ycr-subnet-ru-central1-b,nat-ip-version=ipv4 \
  --create-boot-disk image-folder-id=standard-images,image-family=ubuntu-2004-lts \
  --ssh-key <public_SSH_key_file_path> \
  --service-account-name docker-puller

Where:

  • --name: VM name.
  • --zone: Availability zone matching the subnet.
  • subnet-name: Name of the subnet you created earlier.
  • image-family: Image family.
  • --ssh-key: Public SSH key path.
  • --service-account-name: Service account name.

Result:

id: epd6kj8giu79********
folder_id: b1g681qpemb4********
created_at: "2025-12-12T16:14:50Z"
name: docker-vm
zone_id: ru-central1-b
platform_id: standard-v2
resources:
  memory: "2147483648"
  cores: "2"
  core_fraction: "100"
status: RUNNING
metadata_options:
  gce_http_endpoint: ENABLED
  aws_v1_http_endpoint: ENABLED
  gce_http_token: ENABLED
  aws_v1_http_token: DISABLED
boot_disk:
  mode: READ_WRITE
  device_name: epdvqn83lud9********
  auto_delete: true
  disk_id: epdvqn83lud9********
network_interfaces:
  - index: "0"
    mac_address: d0:0d:**:**:**:**
    subnet_id: e2l8hdblgki4********
    primary_v4_address:
      address: 192.168.1.7
      one_to_one_nat:
        address: 158.***.**.***
        ip_version: IPV4
serial_port_settings:
  ssh_authorization: OS_LOGIN
gpu_settings: {}
fqdn: epd6kj8giu79********.auto.internal
scheduling_policy: {}
service_account_id: ajes3g9rg94s********
network_settings:
  type: STANDARD
placement_policy: {}
hardware_generation:
  legacy_features:
    pci_topology: PCI_TOPOLOGY_V2
application: {}

Use the Create REST API method for the Instance resource or the InstanceService/Create gRPC API call.

Build a Docker image and push it to Cloud RegistryBuild a Docker image and push it to Cloud Registry

Build a Docker image and push it to the registry.

Bash
  1. Get authenticated in Cloud Registry.

  2. Create a file called Dockerfile:

    echo "FROM ubuntu:latest" > Dockerfile
    echo "CMD echo 'Hello World'" >> Dockerfile
    
  3. Build the Docker image:

    docker build . -t registry.yandexcloud.net/<registry_ID>/ubuntu:hello
    

    Where <registry_ID> is the ID of the registry you created earlier.

    Result:

    ...
    Successfully built db45********
    Successfully tagged registry.yandexcloud.net/cn1k31pgpovl********/ubuntu:hello
    
  4. Push the Docker image to the registry:

    docker push registry.yandexcloud.net/<registry_ID>/ubuntu:hello
    

    Result:

    e8bc********: Pushed 
    hello: digest: sha256:96d... size: 529
    

Push the Docker image to the VMPush the Docker image to the VM

Set up the environment on the VM, pull the Docker image, and run it.

Bash
  1. Connect to the VM over SSH.

  2. Install the CLI and restart the terminal:

    curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
    exec -l $SHELL
    
  3. Create a file named key.json and paste the contents of the docker-puller service account key file to it:

    sudo nano key.json
    
  4. Configure the CLI for the service account:

    yc config profile create docker-puller
    yc config set service-account-key key.json
    yc config set folder-id <folder_ID>
    

    For folder-id, specify the ID of the folder containing the registry.

    Result:

    Profile 'docker-puller' created and activated
    
  5. Install Docker:

    sudo apt update
    sudo apt install docker.io
    
  6. Add the current user to the docker group and disconnect from the VM:

    sudo usermod -aG docker $USER
    exit
    
  7. Reconnect to the VM over SSH.

  8. Set up Docker:

    mkdir -p ~/.docker
    cat > ~/.docker/config.json <<'EOF'
    {
      "credHelpers": {
        "registry.yandexcloud.net": "yc"
      }
    }
    EOF
    
    sudo tee /usr/local/bin/docker-credential-yc >/dev/null <<'EOF'
    #!/usr/bin/env bash
    exec yc cloud-registry docker-credential "$@"
    EOF
    
    sudo chmod +x /usr/local/bin/docker-credential-yc
    
  9. Push the Docker image to the VM:

    docker pull registry.yandexcloud.net/<registry_ID>/ubuntu:hello
    

    Result:

    hello: Pulling from cn191rncdrhd********/ubuntu
    02de********: Pull complete
    Digest: sha256:96d...
    Status: Downloaded newer image for registry.yandexcloud.net/cn191rncdrhd********/ubuntu:hello
    registry.yandexcloud.net/cn191rncdrhd********/ubuntu:hello
    
  10. Run the Docker image:

    docker run registry.yandexcloud.net/<registry_ID>/ubuntu:hello
    

    Result:

    Hello World
    

How to delete the resources you createdHow to delete the resources you created

Delete the resources you no longer need to avoid paying for them:

  1. Delete the VM.
  2. Delete the static public IP address if you reserved one.
  3. Delete the network and the subnets.
  4. Delete the Docker image from the registry.
  5. Delete the registry.

See alsoSee also

  • Working with Cloud Registry
  • Creating a VM from a Container Optimized Image

Was the article helpful?

Previous
Deploying Nextcloud on a VM or VM group using Terraform
Next
Resource relationships
© 2026 Direct Cursus Technology L.L.C.