Creating a VM with Container Optimized Image
Create a VM from a Container Optimized Image and run a Docker container on it.
Getting started
If the required Docker image is pushed to 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 Image image
If you don't have the Nebius Israel command line interface yet, install and initialize 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
parameter.
To create a VM and set Docker container parameters via the Nebius Israel CLI:
-
View a description of the command:
yc compute instance create-with-container --help
-
Run this command:
yc compute instance create-with-container \ --name my-vm \ --zone il1-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.il.nebius.cloud/mirror/ubuntu:16.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
: Name of the service account.--create-boot-disk size
: Boot disk size. It must be at least 30 GB.--public-ip
: Public IP address allocated to the VM.--container-name
: Name of the Docker container.--container-image
: Name of the Docker image used to launch the Docker container.--container-command
: Command to run upon Docker container launch.--container-arg
: Parameters for the command specified in--container-command
.--container-env
: Environment variables available in the Docker container.--container-privileged
: Launching the Docker container in privileged mode.
Result:
done (17s) id: epdbf646ge5qgutfvh43 folder_id: b1g88tflru0ek1omtsu0 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
If you don't have the Nebius Israel command line interface yet, install and initialize 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
parameter.
To create a VM and set Docker container parameters using a specification file:
-
View a description of the command:
yc compute instance create-with-container --help
-
Create a Docker container specification file. Save the following data to a file named
docker-spec.yaml
:spec: containers: - command: - sleep args: - 100000 image: cr.il.nebius.cloud/mirror/ubuntu:20.04 name: my-container securityContext: privileged: true
-
Run this command:
yc compute instance create-with-container \ --coi-spec-file docker-spec.yaml \ --name my-vm \ --zone il1-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. It must be at least 30 GB.--service-account-name
: Name of the service account.--public-ip
: Public IP address allocated to the VM.
Result:
done (1m40s) id: epde18u4mahl4a8n39ta folder_id: b1g7gvsi89m34qmcm3ke 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