7.2.8. Create a VM from a container disk by using the CLI


You can create a virtual machine (VM) from a container disk by using the command line.

Prerequisites

  • You must have access credentials for the container registry that contains the container disk.
  • You have installed the virtctl CLI.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a VirtualMachine manifest for your VM and save it as a YAML file. For example, to create a minimal Red Hat Enterprise Linux (RHEL) VM from a container disk, run the following command:

    $ virtctl create vm --name vm-rhel-9 --instancetype u1.small --preference rhel.9 --volume-containerdisk src:registry.redhat.io/rhel9/rhel-guest-image:9.5
  2. Review the VirtualMachine manifest for your VM:

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: vm-rhel-9
    spec:
      instancetype:
        name: u1.small
      preference:
        name: rhel.9
      runStrategy: Always
      template:
        metadata:
          creationTimestamp: null
        spec:
          domain:
            devices: {}
            resources: {}
          terminationGracePeriodSeconds: 180
          volumes:
          - containerDisk:
              image: registry.redhat.io/rhel9/rhel-guest-image:9.5
            name: vm-rhel-9-containerdisk-0
    • metadata.name defines the VM name.
    • spec.instancetype.name defines the instance type to use to control resource sizing of the VM.
    • spec.preference.name defines the preference to use.
    • spec.template.spec.volumes.containerDisk.image defines the URL of the container disk.
  3. Create the VM by running the following command:

    $ oc create -f <vm_manifest_file>.yaml

Verification

  1. Monitor the status of the VM:

    $ oc get vm <vm_name>

    If the provisioning is successful, the VM status is Running. Example output:

    NAME        AGE   STATUS    READY
    vm-rhel-9   18s   Running   True
  2. Verify that provisioning is complete and that the VM has started by accessing its serial console:

    $ virtctl console <vm_name>

    If the VM is running and the serial console is accessible, the output looks as follows:

    Successfully connected to vm-rhel-9 console. The escape sequence is ^]
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동