Skip to content

Compute

OCI Compute instances and block volumes, API version 20160918 (SDK package core, clients ComputeClient and BlockstorageClient; CLI oci compute and oci bv). Each instance runs for real as a Docker container you can SSH into, with its user_data run at first boot and the instance metadata service on 169.254.169.254. Real OCI serves the API on iaas.{region}.{domain}; floci-oci serves it on port 4599 with the other services.

Supported operations

Area Operations
Instances LaunchInstance, GetInstance, ListInstances, UpdateInstance, TerminateInstance, ChangeInstanceCompartment
Power InstanceAction with START, STOP, SOFTSTOP, RESET, SOFTRESET
VNIC attachments AttachVnic, GetVnicAttachment, ListVnicAttachments, DetachVnic
Boot volume attachments GetBootVolumeAttachment, ListBootVolumeAttachments
Volume attachments AttachVolume, GetVolumeAttachment, ListVolumeAttachments, DetachVolume
Block volumes CreateVolume, GetVolume, ListVolumes, UpdateVolume, DeleteVolume, GetVolumeBackupPolicyAssetAssignment (always empty)
Boot volumes GetBootVolume, ListBootVolumes, UpdateBootVolume, DeleteBootVolume
Images GetImage, ListImages, CreateImage, UpdateImage, DeleteImage, ChangeImageCompartment
Shapes ListShapes
Work requests GetWorkRequest, ListWorkRequestErrors, ListWorkRequestLogs on /20160918/workRequests/{id}, /errors and /logs (logs are always empty)
Metadata service GET /opc/v1/... and /opc/v2/...: instance/, instance/<field>, instance/metadata/<key>, instance/regionInfo/<key>, vnics/, identity/cert.pem, identity/key.pem, identity/intermediate.pem
Instance principals The auth service's X.509 federation, POST /v1/x509

Every instance gets one primary VNIC on the subnet in createVnicDetails (or the top-level subnetId). Networking serves it on GetVnic and UpdateVnic (see Networking), which is what the Terraform provider reads back for private_ip, public_ip, hostname_label and create_vnic_details.

Secondary VNICs

AttachVnic adds a secondary VNIC on the subnet in createVnicDetails.subnetId to a RUNNING or STOPPED instance. Networking creates it with isPrimary: false, in the instance's compartment (inferred), with the requested privateIp or the next free address of its subnet, and the attachment is ATTACHED at once (OCI passes through ATTACHING). DetachVnic deletes the VNIC and the attachment is DETACHED at once; terminating the instance detaches every VNIC it has. The metadata service's vnics/ lists the primary VNIC first, then the secondary ones. Every VNIC's private IPs, including secondary ones added with CreatePrivateIp, are on Networking's ListPrivateIps.

A secondary VNIC exists in the API only: the instance's container stays on its one Docker network, nothing answers on the secondary VNIC's address and the guest has no interface for it.

  • A virtual machine has one physical NIC, so nicIndex is 0 (vnic_attachment.go); another value is 400 InvalidParameter.
  • An instance holds at most its shape config's maxVnicAttachments, the primary VNIC included (400 LimitExceeded, inferred).
  • The primary VNIC cannot be detached (409 Conflict, inferred). A VNIC on a VLAN (vlanId without a subnet) is 501 MethodNotImplemented.
  • AttachVnic answers 200 with the attachment and its etag, DetachVnic 204 (inferred).

Moving an instance

ChangeInstanceCompartment answers 202 with the instance's new etag and a work request that is SUCCEEDED at once (the status code is inferred). The instance moves with its VNIC, boot volume and volume attachments; its VNICs, boot volume and block volumes stay in their compartments, as Oracle's documentation for moving instances describes. The Terraform provider finds the primary VNIC by listing the attachments in the instance's compartment, which is why they move (inferred). An instance that is TERMINATING or TERMINATED is 409 IncorrectState. The next instance principal certificate names the new compartment.

How an instance runs

  • One container per instance. The image's family picks the Docker image: oraclelinux:{version} for Oracle Linux and ubuntu:{version} for Ubuntu (config oracle-linux-image and ubuntu-image). PID 1 is tail -f /dev/null; there is no systemd. The container is on the shared Docker network, with a memory limit of the shape config's memoryInGBs and a CPU limit of its vcpus, capped at the Docker host's CPUs.
  • The VNIC address is the container's address. privateIp on the VNIC is the container's IP on its Docker network, recorded at each start. A privateIp given in createVnicDetails is kept as sent, and nothing on Docker answers on it. On macOS, the host cannot reach container IPs; use the SSH host port or a container on the same network.
  • SSH. floci-oci installs openssh-server (and sudo, iproute, socat) with the image's package manager if the image lacks them, so the first boot needs network access to the package repositories. It creates the image's default user, opc on Oracle Linux and ubuntu on Ubuntu (Oracle's Platform Images page), with passwordless sudo and metadata.ssh_authorized_keys added to its ~/.ssh/authorized_keys (keys already there stay, so a container created again from its committed filesystem keeps keys added in the guest), then starts sshd. Port 22 is published on a host port from ssh-base-port..ssh-max-port (12200..12299). The port is not part of the OCI Instance shape; floci-oci logs it when the instance starts:
Compute instance ocid1.instance.oc1.iad... runs in container floci-oci-compute-...: SSH as opc on host port 12200

docker port <container> 22 shows it too. Then ssh -p 12200 opc@localhost. - User data. metadata.user_data is base64, as LaunchInstanceDetails documents. A script that starts with #! runs once as root after the instance is RUNNING, its output appended to /var/log/cloud-init-output.log, for at most user-data-timeout-seconds (600). The limit is enforced inside the guest with timeout: the script and every process in its group get TERM, then KILL 5 seconds later (exit 124 or 137 in the log). #cloud-config user data is applied by floci-oci itself (see Cloud-config). MIME multipart user data is not applied (logged as a warning). - The metadata service. floci-oci serves /opc/v1 and /opc/v2 on its own port and tells callers apart by their source address, which must be the current address of a RUNNING instance's container. A stopped instance has no address there, since Docker hands it to the next container it starts, and an address two instances claim is answered with 404. Inside each instance, 169.254.169.254 is added to the loopback interface with a socat relay to that endpoint, for which the container gets the NET_ADMIN capability and is never privileged (config metadata-proxy, on by default). OCI_METADATA_BASE_URL is set in the container too, as a fallback the OCI SDKs read. When floci-oci runs on the host of Docker Desktop, a container's requests reach it from the VM's address, not the container's, and the metadata service answers 404; run floci-oci in a container on the same network. - Instance principals. See Instance principals below. - Power actions. STOP and SOFTSTOP stop the container (STOPPING, then STOPPED), START starts it again and restarts sshd and the relay (STARTING, then RUNNING), and RESET and SOFTRESET restart it. A container that is gone is created again on START; its user_data does not run again. - Launch failures. An image pull or a container start that fails terminates the instance (TERMINATED, with the work request FAILED and its error on ListWorkRequestErrors). OCI has no FAILED instance state; the mapping is inferred. - Terminate. The instance is TERMINATING until its container and SSH port are gone, then TERMINATED. Its VNIC is deleted, its attachments are DETACHED and its boot volume is TERMINATED, or stays AVAILABLE with preserveBootVolume=true. When Docker refuses to remove the container, or to commit it for a preserved boot volume, the instance stays TERMINATING with the Docker error in lifecycleDetails, keeps its VNIC and SSH port, and the work request is FAILED with that error; sending TerminateInstance again retries. A container that is already gone terminates cleanly. A TERMINATED instance stays readable for terminated-retention-seconds (3600), as the Terraform provider's destroy waits for that state, and is then forgotten. - Block volumes. A volume is a Docker named volume, created the first time the volume is attached and removed once it is deleted and no instance container mounts it: a volume detached from a STOPPED instance stays in that container until its next START or its termination, and a removal Docker refuses is tried again whenever a container is created or removed. An attachment mounts it at /mnt/<device name> in the instance container: /mnt/oraclevdb for device /dev/oracleoci/oraclevdb. A directory, not a block device: there is nothing to partition or format, and isReadOnly mounts it read-only. Docker cannot add a mount to a running container, so attaching to or detaching from a RUNNING instance commits the container's filesystem to an image, then creates the container again from it with the new set of volumes. The attachment is ATTACHING (or DETACHING) until then. The instance stays RUNNING, but its processes restart, as after a reboot, and the container may get a new address, which its VNIC then takes. Attaching to or detaching from a STOPPED instance is ATTACHED (or DETACHED) at once, and its next START creates the container with the new volumes. When the container cannot be created again, the change is undone and its work request is FAILED. - Boot volumes. The container's filesystem is the boot volume. Whenever the container is created again for a volume change, and when an instance is terminated with preserveBootVolume=true, its filesystem is committed to a local image named after the boot volume, and a launch with sourceDetails.sourceType: bootVolume starts from that image, files and installed packages included. DeleteBootVolume, and terminating without preserveBootVolume, remove the image. - Restarts of floci-oci. The SSH host port of every instance that is not TERMINATED, STOPPED ones included, is reserved before anything else, so a new launch cannot take it. A launch that was running terminates the instance; a RUNNING instance has its container started (or created) again, on its old SSH port; a terminate that was running finishes. - State reset. POST /_floci-oci/state/reset removes every instance container, including one a power action still in flight starts after the reset, every boot volume image, every block volume's Docker volume and every custom image's Docker image.

With FLOCI_OCI_SERVICES_COMPUTE_MOCK=true nothing touches Docker: instances are RUNNING as soon as they are launched, power actions and terminate take effect at once, the VNIC gets the next free address of its subnet, and volume attachments are ATTACHED or DETACHED at once.

Instance principals

An SDK inside an instance can authenticate as the instance, as on OCI (InstancePrincipalsAuthenticationDetailsProvider in Java, InstancePrincipalsSecurityTokenSigner in Python, auth.InstancePrincipalConfigurationProvider() in Go):

  1. The SDK reads identity/cert.pem, identity/key.pem and identity/intermediate.pem from the metadata service. floci-oci is the certificate authority: an RSA key made at its start signs a leaf certificate per instance, valid for 24 hours and issued again an hour before it expires or when the instance changes compartment. The leaf's subject carries OU=opc-tenant:<tenancy>, where all three SDKs read the tenancy, and OU=opc-instance: and OU=opc-compartment:. The key is an unencrypted PKCS#1 PEM.
  2. The SDK posts the certificate and a fresh session public key to the auth service, https://auth.<region>.oraclecloud.com/v1/x509. floci-oci serves /v1/x509 on its own port. Inside an instance, OCI_SDK_AUTH_CLIENT_REGION_URL is set to floci-oci's address, which the Go SDK reads; with Python pass federation_endpoint="http://<floci-oci>/v1/x509", and with Java .federationEndpoint("http://<floci-oci>"). The answer is {"token": "<JWT>"} for a certificate floci-oci issued to an instance that is not TERMINATING or TERMINATED, and 401 NotAuthenticated otherwise.
  3. The SDK signs every request with keyId="ST$<token>". The token's tenant is the instance's tenancy and its sub the instance OCID, so requests reach the instance's tenancy and name the instance as their caller. Point the SDK's clients at floci-oci as usual.

With FLOCI_OCI_AUTH_SIGNATURE_VERIFICATION on (known-keys or strict), the /v1/x509 request must be signed with the leaf certificate's key under the keyId the SDKs build, <tenancy>/fed-x509/<SHA-1 fingerprint> (Python) or <tenancy>/fed-x509-sha256/<SHA-256 fingerprint> (Go, Java), the signature must cover x-content-sha256 (the Go and Python federation clients sign the body headers of this POST) and the body must match it, so the session key cannot be swapped; requests made with the token must verify against its jwk claim, the session key, as every security token does (see Identity). In strict mode the token's own signature, made with floci-oci's token key, is checked as well, and so is its exp, so a token minted elsewhere that claims ptype instance is refused. Not covered: IAM policies (dynamic groups and request.principal conditions are not evaluated), the intermediate certificates the SDK sends (ignored), and purpose (ignored, so delegation and service-principal purposes get an ordinary instance token). The token's claims besides tenant, sub and jwk, its one-hour lifetime and the 401 answers are inferred. A restart of floci-oci makes a new authority key and a new token key, so SDKs fetch new certificates when their token next renews, and in strict mode a token issued before the restart is refused.

Cloud-config

The platform image containers run no init system, so cloud-init never starts in them. floci-oci reads #cloud-config user data itself and turns the modules below into one root script, run once like a #! script: after the instance is RUNNING, with the same time limit, its output in /var/log/cloud-init-output.log. The modules run in cloud-init's order, and one that fails is reported in the log without stopping the next, as in cloud-init.

Key Applied as
bootcmd Run first, once (cloud-init runs it at every boot). A string runs with sh -c, a list as its own argv.
write_files path, content, encoding (b64, base64 or text), permissions (default 0644), owner, append. Entries with defer: true are written after packages, so their owner can be a user users creates. Gzip encodings are skipped with a log line.
groups A group name, or a mapping of a group to its members.
users default (the image's user, already created) or a mapping with name, gecos, homedir, shell, primary_group, groups (list or comma-separated), sudo (a rule or a list of rules, in /etc/sudoers.d/90-cloud-init-users), system and ssh_authorized_keys.
ssh_authorized_keys Added to the image's default user, after metadata.ssh_authorized_keys.
timezone /etc/localtime linked to the zone.
package_update, package_upgrade, packages dnf or apt-get, as the image has. A package is a name or a [name, version] pair.
runcmd Run last. A string runs with sh -c, a list as its own argv.
final_message Echoed to the log.

Any other key (hostname, fqdn, mounts, chpasswd, ntp, apt sources, yum_repos, power_state, Jinja templates and the rest) is named in a warning and in the log, and not applied. User data that is not a YAML mapping is not run.

Wire notes

  • LaunchInstance and UpdateInstance answer 200 with the Instance, its etag and opc-work-request-id; InstanceAction answers 200 with the Instance and its etag; TerminateInstance answers 204 with opc-work-request-id. The SDKs record no status codes; these are inferred.
  • Every list is a bare JSON array with opc-next-page (unlike Container Instances' {"items"}). ListBootVolumeAttachments requires both availabilityDomain and compartmentId; ListVolumeAttachments requires compartmentId; ListVolumes and ListBootVolumes take every filter as optional, as the SDKs declare.
  • CreateVolume and AttachVolume answer 200 with the resource and its etag (AttachVolume also with opc-work-request-id); DeleteVolume, DeleteBootVolume and DetachVolume answer 204 (DetachVolume with opc-work-request-id). The status codes are inferred.
  • A volume attachment is paravirtualized, iscsi or emulated, as type asks; service_determined is answered as paravirtualized (inferred) and nvme is 501 MethodNotImplemented. An iscsi attachment carries the mandatory ipv4, iqn and port, with inferred values that no iSCSI target answers. Without a device, the attachment gets the first free one of /dev/oracleoci/oraclevdb to oraclevdz (inferred). The attachment's compartmentId is its instance's. The work request resource has entityType: volumeattachment (inferred).
  • A volume created without a size is 1024 GB (inferred from Oracle's documentation); sizeInMBs is rounded up to whole GB. vpusPerGB defaults to 10. Boot volumes and volumes carry etag; the etags of boot volumes and volume attachments are derived from their state.
  • region on an Instance is iad or phx for us-ashburn-1 and us-phoenix-1 and the full name otherwise, as the field's documentation says.
  • metadata and extendedMetadata are echoed as sent, and so are launchOptions, agentConfig, availabilityConfig, instanceOptions, platformConfig and preemptibleInstanceConfig. sourceDetails is echoed with sourceType: image; with only the deprecated top-level imageId, it is built from it.
  • The work request resource has entityType: instance (CREATED, UPDATED or DELETED). Launch's work request finishes when the instance is RUNNING. Update's is SUCCEEDED at once, except for a shape change in real mode (see below).
  • Platform images carry no compartmentId, which the Terraform provider expects of official images.
  • An instance action that is not emulated (SENDDIAGNOSTICINTERRUPT, DIAGNOSTICREBOOT, REBOOTMIGRATE) is 501 MethodNotImplemented; one outside the enum is 400 InvalidParameter.

Validation

  • availabilityDomain must be one of the tenancy's, faultDomain one of FAULT-DOMAIN-1 to 3 (FAULT-DOMAIN-1 when left out).
  • shape must be in the catalog below and shapeConfig within its range; a fixed shape takes no other size.
  • The image must be a platform image or an AVAILABLE custom image (400 RelatedResourceNotAuthorizedOrNotFound). A sourceType: bootVolume launch needs a boot volume that exists and is not TERMINATED (400 RelatedResourceNotAuthorizedOrNotFound), in the launch's availability domain (400 InvalidParameter), and attached to no instance (409 Conflict).
  • A volume is 50 GB to 32768 GB and vpusPerGB a multiple of 10 from 0 to 120 (400 InvalidParameter; the bounds are inferred from Oracle's documentation). UpdateVolume and UpdateBootVolume only grow a volume. CreateVolume from a backup, a replica or another volume is 501 MethodNotImplemented.
  • AttachVolume needs a RUNNING or STOPPED instance (409 IncorrectState), a volume in the instance's availability domain (400 InvalidParameter), a device of the form /dev/oracleoci/oraclevd<letters> (400 InvalidParameter) the instance does not use yet, and a volume that is not attached already, unless both attachments are isShareable (409 Conflict). An attached volume cannot be deleted, nor a boot volume attached to an instance (409 IncorrectState). Terminating an instance detaches its volumes.
  • The subnet and NSGs must exist in Networking (400 RelatedResourceNotAuthorizedOrNotFound), the NSGs in the subnet's VCN.
  • if-match is checked on update, instance actions and terminate (412 NoEtagMatch).
  • An action on a TERMINATING or TERMINATED instance, START of one that is not STOPPED, STOP of one that is not RUNNING and RESET of one that is not RUNNING are 409 IncorrectState. START of a running instance and STOP of a stopped one change nothing (inferred).
  • A subnet, VCN or NSG an instance still uses cannot be deleted (409 Conflict), nor a compartment that holds an instance, a preserved boot volume or a volume.

Images and shapes

Images (ListImages filters on operatingSystem, operatingSystemVersion, displayName and shape; each image runs on every shape):

Display name operatingSystem operatingSystemVersion Docker image User
Oracle-Linux-9.5-2025.01.31-0 Oracle Linux 9 oraclelinux:9 opc
Oracle-Linux-8.10-2025.01.31-0 Oracle Linux 8 oraclelinux:8 opc
Canonical-Ubuntu-24.04-2025.01.31-0 Canonical Ubuntu 24.04 ubuntu:24.04 ubuntu
Canonical-Ubuntu-22.04-2025.01.31-0 Canonical Ubuntu 22.04 ubuntu:22.04 ubuntu

Image OCIDs are derived from the region and the name, so they are the same on every run.

Custom images

CreateImage takes an image of a RUNNING or STOPPED instance (instanceId) into compartmentId. The image keeps the operating system, version and default user of the platform image the instance came from, and its baseImageId is the instance's image. ListImages lists a compartment's custom images beside the platform images, and a launch with sourceType: image takes one like a platform image.

  • Real mode. The image is PROVISIONING while the instance's container, running or stopped, is committed to a local Docker image, then AVAILABLE, and the work request (entityType: image) SUCCEEDED. The commit waits for the instance's pending power or volume changes and runs before later ones. The instance keeps running; OCI stops it while the image is taken. An instance whose container is gone is imaged from its boot volume's committed image. When the commit fails the image is DELETED and its work request FAILED (OCI has no failed image state; inferred), and a restart of floci-oci during a commit ends the same way.
  • Launching from a custom image copies the image to the new boot volume first, so the instance keeps its files when the image is deleted later, and every container created again for it starts from that copy.
  • Mock mode. The image is AVAILABLE at once.
  • UpdateImage changes the display name, operatingSystem, operatingSystemVersion and the tags, and ChangeImageCompartment moves the image at once (200 with its etag; the SDKs declare no work request). Both check if-match.
  • DeleteImage makes the image DELETED at once and removes its Docker image; the image stays readable as DELETED, and ListImages shows it only with lifecycleState=DELETED (inferred). An image still PROVISIONING cannot be deleted, nor one that an instance launched from it and still PROVISIONING has not copied yet (409 IncorrectState, inferred). A launch from a boot volume works after its image is deleted.
  • A platform image belongs to Oracle: UpdateImage, DeleteImage and ChangeImageCompartment on one are 404 NotAuthorizedOrNotFound (inferred).
  • CreateImage answers 200 with the image, its etag and opc-work-request-id, DeleteImage 204 (inferred). launchMode defaults to PARAVIRTUALIZED, the instances' own mode. The size is the platform image's (inferred).
  • Importing an image from Object Storage (imageSourceDetails) is 501 MethodNotImplemented; exporting one is not served.
  • A compartment that holds a custom image that is not DELETED cannot be deleted.

Shapes (the series come from the Compute service limits; the processor descriptions and the bounds are inferred):

Shape Flexible OCPUs Memory
VM.Standard.E4.Flex yes 1 to 64 1 GB to 64 GB per OCPU, at most 1024 GB; 16 GB per OCPU by default
VM.Standard.E5.Flex yes 1 to 94 at most 1049 GB; 12 GB per OCPU by default
VM.Standard.A1.Flex yes 1 to 80 at most 512 GB; 6 GB per OCPU by default
VM.Standard3.Flex yes 1 to 32 at most 512 GB; 16 GB per OCPU by default
VM.Standard.E2.1.Micro no 1 1 GB
VM.Standard2.1 no 1 15 GB

A flexible shape launched without shapeConfig gets 1 OCPU (inferred). A boot volume is 47 GB unless sourceDetails.bootVolumeSizeInGBs says otherwise (inferred). Sizes are recorded, not enforced: the container's filesystem and the Docker volumes take what the Docker host has.

Quickstart

export OCI_CLI_ENDPOINT=http://localhost:4599
IMAGE=$(oci compute image list -c "$COMPARTMENT" --operating-system "Oracle Linux" \
  --operating-system-version 9 --query 'data[0].id' --raw-output)
oci compute instance launch -c "$COMPARTMENT" --availability-domain "$AD" \
  --shape VM.Standard.E4.Flex --shape-config '{"ocpus": 1, "memoryInGBs": 4}' \
  --image-id "$IMAGE" --subnet-id "$SUBNET" \
  --ssh-authorized-keys-file ~/.ssh/id_ed25519.pub \
  --user-data-file ./init.sh --wait-for-state RUNNING

Notes and limitations

  • A shape change on UpdateInstance sets the container's memory and CPU limits in place, so its processes keep running; on OCI a running instance reboots to change shape. Its work request is IN_PROGRESS until Docker has applied the limits. When Docker refuses them, the work request is FAILED with Docker's error. The instance record follows the latest shape change: when it succeeds the instance has the shape it asked for, and when Docker refuses it the instance takes back the shape its container last took; an earlier change that a later one overtook only closes its work request (inferred). A shape change still waiting when floci-oci restarts is applied after the restart, and fails its work request if the instance did not survive it.
  • The Terraform provider waits on an update's work request through its shared work request client, which has no host override: an update that changes shape, shape_config or fault_domain reaches real OCI. Display name, tags and metadata changes do not wait.
  • Attaching or detaching a volume on a RUNNING instance restarts its processes (see Block volumes above); on real OCI it does not.
  • Not emulated: volume backups, clones, replicas and groups, CreateBootVolume, volume and boot volume ChangeCompartment, KMS keys on volumes (kmsKeyId is echoed), instance configurations and pools, console connections and history, image import and export, MIME multipart user data, IPv6, and a data path for secondary VNICs (see Secondary VNICs).