Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Container Registry
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Authentication in Yandex Container Registry
    • Managing a Docker image
      • Getting information about available Docker images
      • Creating a Docker image
      • Pushing a Docker image to a registry
      • Pulling a Docker image from a registry
      • Deleting a Docker image from a registry
    • Managing a registry
      • Getting information about existing registries
      • Creating a registry
      • Updating a registry
      • Deleting a registry
    • Managing a repository
      • Getting information about existing repositories
    • Managing policies for automatically deleting Docker images
      • Getting information about existing lifecycle policies
      • Creating a lifecycle policy
      • Updating a lifecycle policy
      • Performing lifecycle policy dry runs
      • Deleting a lifecycle policy
    • Working with roles
      • Assign a role
      • Viewing assigned roles
      • Revoke a role
  • Yandex Container Solution
  • Use cases
    • All use cases
    • Running a Docker image on a VM
  • Concepts
    • Overview
    • Docker image
    • Registry
    • Repository
    • Policies for automatically deleting Docker images
    • Backups
    • Quotas and limits
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ImageService
      • LifecyclePolicyService
      • RegistryService
      • RepositoryService
      • ScannerService
      • OperationService
    • REST
      • Overview
      • Image
        • Overview
        • delete
        • get
        • list
      • LifecyclePolicy
        • Overview
      • Registry
        • Overview
        • create
        • delete
        • get
        • list
        • listAccessBindings
        • setAccessBindings
        • update
        • updateAccessBindings
      • Repository
        • Overview
        • get
        • list
        • listAccessBindings
        • setAccessBindings
        • updateAccessBindings
      • Scanner
        • Overview
  • Troubleshooting
  • Questions and answers
  1. Use cases
  2. Running a Docker image on a VM

Running a Docker image on a VM

    This example describes the steps required to run a Docker image on a VM using a registry.
    If you don't have a VM yet, create one.

    1. Add variables for convenience:

      • Address of your VM in the ${INSTANCE_ID} variable:

        $ export INSTANCE_ID=ef3ni90g6qblknkph60v
        
      • Your OAuth token in the ${OAUTH} variable:

        $ export OAUTH=AQAAAAAV6O...
        
      • Your IAM token in the ${IAM} variable:

        $ export IAM=CggaATEVAg...
        
      • Registry ID from the example in the ${REGISTRY_ID} variable:

        $ export REGISTRY_ID=crpc9qeoft236r8tfalm
        
    2. Create an Ubuntu-based Docker image from the example:

      $ docker build . \
      -t cr.yandex/${REGISTRY_ID}/ubuntu:hello
      
    3. Log in to the registry under your username:

      $ docker login \
      --username oauth \
      --password ${OAUTH} \
      cr.yandex
      
    4. Push the created Docker image to Yandex Cloud Registry:

      $ docker push \
      cr.yandex/${REGISTRY_ID}/ubuntu:hello
      
    5. Log in to the VM via SSH and authenticate as the service account associated with this VM:

      $ ssh ${INSTANCE_ID} docker login \
      --username iam \
      --password ${IAM} \
      cr.yandex
      
    6. Pull the Docker image to the VM:

      $ ssh ${INSTANCE_ID} \
      docker pull cr.yandex/${REGISTRY_ID}/ubuntu:hello
      
    7. Run the Docker image on the VM:

      $ ssh ${INSTANCE_ID} \
      docker run cr.yandex/${REGISTRY_ID}/ubuntu:hello
      
    Language / Region
    Careers
    Privacy policy
    Terms of use
    Brandbook
    © 2021 Yandex.Cloud LLC