OpenMCF logoOpenMCF

Loading...

OCI Container Instance

Deploys an Oracle Cloud Infrastructure Container Instance — OCI's serverless container service for running one or more containers in a pod-like construct without managing compute infrastructure. Containers within an instance share networking (VNICs) and volumes, communicate over localhost, and support HTTP/TCP health checks, Linux security contexts, and image pull secrets for private registries. Shapes are always flex (CI.Standard.E4.Flex, CI.Standard.E3.Flex), with configurable OCPU and memory allocation.

What Gets Created

When you deploy an OciContainerInstance resource, OpenMCF provisions:

  • Container Instance — an oci_container_instances_container_instance resource in the specified compartment and availability domain. The instance runs one or more containers sharing the same network namespace and volume mounts, using the specified flex shape and OCPU/memory allocation. Each container can have independent health checks, resource limits, security contexts, and volume mounts. Standard OpenMCF freeform tags are applied for resource tracking.

Prerequisites

  • OCI credentials configured via environment variables or OpenMCF provider config (API Key, Instance Principal, Security Token, Resource Principal, or OKE Workload Identity)
  • A compartment OCID where the container instance will be created — literal value or reference to an OciCompartment resource
  • An availability domain name (e.g., Uocm:PHX-AD-1) — run oci iam availability-domain list to see domains in your region
  • A subnet OCID for the instance's VNIC — literal value or reference to an OciSubnet resource
  • A container image URL accessible from the subnet (e.g., docker.io/library/nginx:latest). For private registries, configure imagePullSecrets

Quick Start

Create a file container-instance.yaml:

apiVersion: oci.openmcf.org/v1
kind: OciContainerInstance
metadata:
  name: web-server
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.OciContainerInstance.web-server
spec:
  compartmentId:
    value: "ocid1.compartment.oc1..example"
  availabilityDomain: "Uocm:PHX-AD-1"
  shape: "CI.Standard.E4.Flex"
  shapeConfig:
    ocpus: 1
  containers:
    - imageUrl: "docker.io/library/nginx:latest"
  vnics:
    - subnetId:
        value: "ocid1.subnet.oc1.iad.example"

Deploy:

openmcf apply -f container-instance.yaml

This creates a single-container instance running nginx on a 1-OCPU E4 Flex shape. OCI assigns memory based on the OCPU count (minimum 1 GB per OCPU). The container uses the default restart policy (ALWAYS) and inherits DNS settings from the subnet's DHCP options. The container instance ID and container IDs are exported as stack outputs.

Configuration Reference

Required Fields

FieldTypeDescriptionValidation
compartmentIdStringValueOrRefOCID of the compartment where the container instance will be created. Can reference an OciCompartment resource via valueFrom.Required
availabilityDomainstringAvailability domain where the container instance runs. Example: Uocm:PHX-AD-1.Minimum 1 character
shapestringCompute shape for the container instance. Container Instance shapes are always flex. Example: CI.Standard.E4.Flex, CI.Standard.E3.Flex.Minimum 1 character
shapeConfigShapeConfigCPU and memory allocation for the entire container instance. Individual containers can set resource limits within this envelope. See shapeConfig fields.Required
containersContainer[]Containers to run on this instance. Multiple containers share the same network namespace and can communicate over localhost. See container fields.Minimum 1 item
vnicsVnic[]Virtual network interface cards providing network connectivity. Each VNIC is attached to a subnet. All containers share the instance's VNICs. See vnic fields.Minimum 1 item

Optional Fields

FieldTypeDefaultDescription
displayNamestringmetadata.nameHuman-readable name for the container instance shown in the OCI Console.
containerRestartPolicyenumalwaysRestart policy applied to all containers. Values: always, never, on_failure.
faultDomainstringAuto-selectedFault domain within the availability domain. Example: FAULT-DOMAIN-1. When omitted, OCI selects a fault domain automatically.
gracefulShutdownTimeoutInSecondsint64—Seconds to wait for containers to gracefully terminate before forcefully stopping them. Applies when the instance is stopped or deleted.
dnsConfigDnsConfigSubnet DHCPDNS resolver configuration for containers. When omitted, containers inherit DNS settings from the subnet's DHCP options. See dnsConfig fields.
imagePullSecretsImagePullSecret[]—Credentials for pulling container images from private registries. Supports basic authentication and OCI Vault-based credentials. See imagePullSecret fields.
volumesVolume[]—Volumes accessible to containers via volume mounts. A container instance supports up to 32 volumes. See volume fields.

shapeConfig Fields

FieldTypeDescriptionValidation
ocpusfloatNumber of OCPUs allocated to the container instance. Example: 1.0, 2.0, 4.0.Greater than 0
memoryInGbsfloatMemory in gigabytes. When omitted, OCI assigns a default based on the OCPU count (minimum 1 GB per OCPU).Optional

container Fields

FieldTypeDescriptionValidation
imageUrlstringContainer image URL. Example: docker.io/library/nginx:latest, ghcr.io/org/app:v1.2. Default registry is docker.io/library if not specified.Minimum 1 character
displayNamestringHuman-readable name for the container.Optional
commandstring[]Overrides the image's ENTRYPOINT. Each element is a separate argument.Optional
argumentsstring[]Arguments passed to the ENTRYPOINT process. Total size of all arguments combined must be <= 64 KB.Optional
environmentVariablesmap<string, string>Environment variables injected into the container. Total size of all names + values combined must be <= 64 KB.Optional
workingDirectorystringWorking directory for the container's entrypoint process.Optional
isResourcePrincipalDisabledboolWhen true, disables OCI resource principal access for this container. Resource principal (v2.2) is enabled by default.Optional
resourceConfigContainerResourceConfigCPU and memory limits for this container within the instance-level envelope. When omitted, the container can use all resources available to the instance. See containerResourceConfig fields.Optional
healthChecksHealthCheck[]Health checks for monitoring container readiness. Supports HTTP and TCP probe types. See healthCheck fields.Optional
securityContextSecurityContextLinux security settings for the container process. See securityContext fields.Optional
volumeMountsVolumeMount[]Volumes to mount into this container's filesystem. See volumeMount fields.Optional

containerResourceConfig Fields

FieldTypeDescription
memoryLimitInGbsfloatMaximum memory in gigabytes the container can consume. When omitted, the container can use all available instance memory.
vcpusLimitfloatMaximum logical CPUs the container can consume. 1 OCPU = 2 logical CPUs. Values can be fractional (e.g., 0.5). When omitted, the container can use all available instance CPUs.

healthCheck Fields

FieldTypeDescriptionValidation
healthCheckTypeenumProtocol for the health check. Values: http, tcp.Required (cannot be unspecified)
portint32Port to probe.Greater than 0
namestringName for the health check, unique within the container instance.Optional
pathstringURL path for HTTP health checks. Required when healthCheckType is http. Example: /healthz.Optional
failureActionenumAction to take when the health check fails. Values: kill, none. Default: kill.Optional
failureThresholdint32Consecutive failures required to consider the container unhealthy.Optional
successThresholdint32Consecutive successes required to consider the container healthy again.Optional
initialDelayInSecondsint32Seconds to wait after container start before running the first check.Optional
intervalInSecondsint32Seconds between consecutive health checks.Optional
timeoutInSecondsint32Seconds to wait for a health check response before considering it failed.Optional
headersHealthCheckHeader[]Custom HTTP headers sent with HTTP health checks. Each header has name and value string fields.Optional

securityContext Fields

FieldTypeDescription
isNonRootUserCheckEnabledboolWhen true, validates at runtime that the container does not run as UID 0. Fails the container start if the image runs as root.
isRootFileSystemReadonlyboolWhen true, the container's root filesystem is mounted read-only.
runAsUserint32User ID (UID) for the container's entrypoint process. Defaults to the UID specified in the container image.
runAsGroupint32Group ID (GID) for the container's entrypoint process. When specified, runAsUser should also be provided.
capabilitiesCapabilitiesLinux capabilities to add or drop from the container process. See capabilities fields.

capabilities Fields

FieldTypeDescription
addCapabilitiesstring[]Capabilities to add to the container process. Example: ["NET_ADMIN", "SYS_TIME"].
dropCapabilitiesstring[]Capabilities to drop from the container process. Example: ["ALL"].

volumeMount Fields

FieldTypeDescriptionValidation
mountPathstringPath inside the container where the volume is mounted. Example: /data, /etc/config.Minimum 1 character
volumeNamestringName of the volume to mount. Must match a volume defined in the instance-level volumes list.Minimum 1 character
isReadOnlyboolWhen true, the volume is mounted read-only.Optional
partitionint32If the volume has partitions, the partition number to mount.Optional
subPathstringSub-path within the volume to mount instead of the volume root.Optional

vnic Fields

FieldTypeDescriptionValidation
subnetIdStringValueOrRefOCID of the subnet in which to create the VNIC. Can reference an OciSubnet resource via valueFrom.Required
displayNamestringHuman-readable name for the VNIC.Optional
hostnameLabelstringHostname label for the VNIC's primary private IP in subnet DNS.Optional
isPublicIpAssignedboolWhether to assign a public IP to the VNIC. When omitted, uses the subnet's default public IP assignment setting.Optional
nsgIdsStringValueOrRef[]OCIDs of network security groups to add this VNIC to. Can reference OciSecurityGroup resources via valueFrom.Optional
privateIpstringStatic private IP address within the subnet's CIDR. When omitted, OCI assigns one automatically.Optional
skipSourceDestCheckboolWhen true, disables source/destination checking on the VNIC. Required for NAT instances or virtual routers.Optional

dnsConfig Fields

FieldTypeDescription
nameserversstring[]IP addresses of DNS name servers (IPv4 or IPv6). When omitted, uses nameservers from the subnet's DHCP options.
optionsstring[]Resolver options in resolv.conf format. Example: ["ndots:5", "edns0"].
searchesstring[]Search domains for unqualified hostname lookups. When omitted, uses searches from the subnet's DHCP options.

imagePullSecret Fields

FieldTypeDescriptionValidation
registryEndpointstringRegistry endpoint URL. Example: ghcr.io, docker.io, us-ashburn-1.ocir.io.Minimum 1 character
secretTypeenumAuthentication method for the registry. Values: basic, vault.Required (cannot be unspecified)
usernamestringUsername for basic authentication. Required when secretType is basic. Must be base64-encoded.Optional
passwordstringPassword for basic authentication. Required when secretType is basic. Must be base64-encoded.Optional
secretIdStringValueOrRefOCID of an OCI Vault secret containing registry credentials. Required when secretType is vault.Optional

volume Fields

FieldTypeDescriptionValidation
namestringUnique name for this volume within the container instance. Containers reference this name in their volumeMounts.Minimum 1 character
volumeTypeenumStorage backing for the volume. Values: emptydir, configfile.Required (cannot be unspecified)
backingStorestringBacking store for emptydir volumes. Options: EPHEMERAL_STORAGE (disk-backed) or MEMORY (tmpfs). Only applicable when volumeType is emptydir.Optional
configsVolumeConfig[]Config file entries for configfile volumes. Each entry becomes a file in the volume. Only applicable when volumeType is configfile. See volumeConfig fields.Optional

volumeConfig Fields

FieldTypeDescription
datastringBase64-encoded contents of the file. Decoded to plain text at mount time.
fileNamestringName of the file within the volume. Must be unique across the volume.
pathstringRelative path within the volume mount directory. When omitted, the file is placed at the volume mount root.

Examples

Minimal Single-Container Instance

A single nginx container — the simplest path to running a container on OCI:

apiVersion: oci.openmcf.org/v1
kind: OciContainerInstance
metadata:
  name: web-server
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: my-org
    pulumi.openmcf.org/project: my-project
    pulumi.openmcf.org/stack.name: dev.OciContainerInstance.web-server
spec:
  compartmentId:
    value: "ocid1.compartment.oc1..example"
  availabilityDomain: "Uocm:PHX-AD-1"
  shape: "CI.Standard.E4.Flex"
  shapeConfig:
    ocpus: 1
  containers:
    - imageUrl: "docker.io/library/nginx:latest"
  vnics:
    - subnetId:
        value: "ocid1.subnet.oc1.iad.example"

Multi-Container Instance with Shared Volume

A web application container with a Fluent Bit sidecar collecting logs via a shared emptydir volume — the pod-like multi-container pattern:

apiVersion: oci.openmcf.org/v1
kind: OciContainerInstance
metadata:
  name: web-with-logging
  org: acme
  env: prod
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: acme
    pulumi.openmcf.org/project: platform
    pulumi.openmcf.org/stack.name: prod.OciContainerInstance.web-with-logging
spec:
  compartmentId:
    valueFrom:
      kind: OciCompartment
      name: prod-compartment
      fieldPath: status.outputs.compartmentId
  availabilityDomain: "Uocm:PHX-AD-1"
  shape: "CI.Standard.E4.Flex"
  shapeConfig:
    ocpus: 2
    memoryInGbs: 8
  containerRestartPolicy: always
  containers:
    - imageUrl: "ghcr.io/acme/web-app:v2.1"
      displayName: "web-app"
      resourceConfig:
        memoryLimitInGbs: 6
        vcpusLimit: 3
      environmentVariables:
        LOG_DIR: "/var/log/app"
        PORT: "8080"
      healthChecks:
        - healthCheckType: http
          port: 8080
          path: "/healthz"
          initialDelayInSeconds: 10
          intervalInSeconds: 15
          timeoutInSeconds: 5
          failureThreshold: 3
      volumeMounts:
        - mountPath: "/var/log/app"
          volumeName: "shared-logs"
    - imageUrl: "docker.io/fluent/fluent-bit:latest"
      displayName: "log-collector"
      resourceConfig:
        memoryLimitInGbs: 1
        vcpusLimit: 0.5
      volumeMounts:
        - mountPath: "/var/log/app"
          volumeName: "shared-logs"
          isReadOnly: true
  vnics:
    - subnetId:
        valueFrom:
          kind: OciSubnet
          name: app-subnet
          fieldPath: status.outputs.subnetId
      nsgIds:
        - valueFrom:
            kind: OciSecurityGroup
            name: app-nsg
            fieldPath: status.outputs.networkSecurityGroupId
  volumes:
    - name: "shared-logs"
      volumeType: emptydir
      backingStore: "EPHEMERAL_STORAGE"

Hardened Production Instance with Private Registry

A production container with a read-only root filesystem, non-root user enforcement, dropped capabilities, health checks, config file injection, and OCI Vault-based image pull credentials:

apiVersion: oci.openmcf.org/v1
kind: OciContainerInstance
metadata:
  name: secure-api
  org: acme
  env: prod
  labels:
    openmcf.org/provisioner: pulumi
    pulumi.openmcf.org/organization: acme
    pulumi.openmcf.org/project: platform
    pulumi.openmcf.org/stack.name: prod.OciContainerInstance.secure-api
spec:
  compartmentId:
    valueFrom:
      kind: OciCompartment
      name: prod-compartment
      fieldPath: status.outputs.compartmentId
  availabilityDomain: "Uocm:PHX-AD-1"
  faultDomain: "FAULT-DOMAIN-1"
  shape: "CI.Standard.E4.Flex"
  shapeConfig:
    ocpus: 4
    memoryInGbs: 16
  gracefulShutdownTimeoutInSeconds: 30
  containers:
    - imageUrl: "us-ashburn-1.ocir.io/acme-tenancy/api-service:v3.0"
      displayName: "api-service"
      command:
        - "/app/server"
      arguments:
        - "--config=/etc/app/config.json"
        - "--port=8443"
      environmentVariables:
        APP_ENV: "production"
        LOG_LEVEL: "info"
      resourceConfig:
        memoryLimitInGbs: 14
        vcpusLimit: 7
      securityContext:
        isNonRootUserCheckEnabled: true
        isRootFileSystemReadonly: true
        runAsUser: 1000
        runAsGroup: 1000
        capabilities:
          dropCapabilities:
            - "ALL"
          addCapabilities:
            - "NET_BIND_SERVICE"
      healthChecks:
        - healthCheckType: http
          port: 8443
          path: "/healthz"
          name: "readiness"
          initialDelayInSeconds: 15
          intervalInSeconds: 10
          timeoutInSeconds: 5
          failureThreshold: 3
          successThreshold: 1
        - healthCheckType: tcp
          port: 8443
          name: "liveness"
          intervalInSeconds: 30
          failureThreshold: 5
          failureAction: kill
      volumeMounts:
        - mountPath: "/etc/app"
          volumeName: "app-config"
          isReadOnly: true
        - mountPath: "/tmp"
          volumeName: "tmp-dir"
  vnics:
    - subnetId:
        valueFrom:
          kind: OciSubnet
          name: private-subnet
          fieldPath: status.outputs.subnetId
      isPublicIpAssigned: false
      nsgIds:
        - valueFrom:
            kind: OciSecurityGroup
            name: api-nsg
            fieldPath: status.outputs.networkSecurityGroupId
  imagePullSecrets:
    - registryEndpoint: "us-ashburn-1.ocir.io"
      secretType: vault
      secretId:
        value: "ocid1.vaultsecret.oc1.iad.example"
  dnsConfig:
    searches:
      - "internal.acme.com"
      - "svc.acme.com"
  volumes:
    - name: "app-config"
      volumeType: configfile
      configs:
        - fileName: "config.json"
          data: "eyJkYXRhYmFzZSI6eyJob3N0IjoiZGIuaW50ZXJuYWwifX0="
    - name: "tmp-dir"
      volumeType: emptydir
      backingStore: "MEMORY"

Stack Outputs

After deployment, the following outputs are available in status.outputs:

OutputTypeDescription
container_instance_idstringOCID of the container instance.
container_idsstringComma-separated OCIDs of the individual containers within the instance. Useful for operational tasks (viewing logs, exec into container).

Related Components

  • OciCompartment — provides the compartment referenced by compartmentId via valueFrom
  • OciSubnet — provides subnets for VNIC attachment (vnics[].subnetId) via valueFrom
  • OciSecurityGroup — manages network security rules for instance VNICs (vnics[].nsgIds) via valueFrom

Next article

OCI DB System

OCI DB System Deploys an Oracle Cloud Infrastructure Database System — a managed Oracle Database running on Virtual Machine or Bare Metal infrastructure. The component provisions the underlying compute and storage, a DB Home containing the Oracle Database software, and an initial database instance as an inseparable unit. What Gets Created When you deploy an OciDbSystem resource, OpenMCF provisions: Database DB System — an ocidatabasedbsystem resource in the specified compartment and subnet....
Read next article
Presets
3 ready-to-deploy configurationsView presets →