# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
import oci
# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()
# Initialize service client with default config file
container_instances_client = oci.container_instances.ContainerInstanceClient(
config)
# Send the request to service, some parameters are not required, see API
# doc for more info
create_container_instance_response = container_instances_client.create_container_instance(
create_container_instance_details=oci.container_instances.models.CreateContainerInstanceDetails(
compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
availability_domain="EXAMPLE-availabilityDomain-Value",
shape="EXAMPLE-shape-Value",
shape_config=oci.container_instances.models.CreateContainerInstanceShapeConfigDetails(
ocpus=6812.4873,
memory_in_gbs=2322.4885),
containers=[
oci.container_instances.models.CreateContainerDetails(
image_url="EXAMPLE-imageUrl-Value",
display_name="EXAMPLE-displayName-Value",
command=["EXAMPLE--Value"],
arguments=["EXAMPLE--Value"],
working_directory="EXAMPLE-workingDirectory-Value",
environment_variables={
'EXAMPLE_KEY_pT4OK': 'EXAMPLE_VALUE_6m7RSszLIcYdL0wPTICG'},
volume_mounts=[
oci.container_instances.models.CreateVolumeMountDetails(
mount_path="EXAMPLE-mountPath-Value",
volume_name="EXAMPLE-volumeName-Value",
sub_path="EXAMPLE-subPath-Value",
is_read_only=True,
partition=58)],
is_resource_principal_disabled=False,
resource_config=oci.container_instances.models.CreateContainerResourceConfigDetails(
vcpus_limit=8066.2695,
memory_limit_in_gbs=3138.9778),
health_checks=[
oci.container_instances.models.CreateContainerHttpHealthCheckDetails(
health_check_type="HTTP",
path="EXAMPLE-path-Value",
port=53871,
name="EXAMPLE-name-Value",
initial_delay_in_seconds=74,
interval_in_seconds=575,
failure_threshold=728,
success_threshold=595,
timeout_in_seconds=156,
failure_action="KILL",
headers=[
oci.container_instances.models.HealthCheckHttpHeader(
name="EXAMPLE-name-Value",
value="EXAMPLE-value-Value")])],
security_context=oci.container_instances.models.CreateLinuxSecurityContextDetails(
security_context_type="LINUX",
run_as_user=50763,
run_as_group=44,
is_non_root_user_check_enabled=True,
is_root_file_system_readonly=True,
capabilities=oci.container_instances.models.ContainerCapabilities(
add_capabilities=["CAP_SETPCAP"],
drop_capabilities=["ALL"])),
freeform_tags={
'EXAMPLE_KEY_VePXx': 'EXAMPLE_VALUE_6yXsyv6HyxsDCt5GeLru'},
defined_tags={
'EXAMPLE_KEY_u0Q6z': {
'EXAMPLE_KEY_Ju5Xc': 'EXAMPLE--Value'}})],
vnics=[
oci.container_instances.models.CreateContainerVnicDetails(
subnet_id="ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
display_name="EXAMPLE-displayName-Value",
hostname_label="EXAMPLE-hostnameLabel-Value",
is_public_ip_assigned=False,
skip_source_dest_check=True,
nsg_ids=["EXAMPLE--Value"],
private_ip="EXAMPLE-privateIp-Value",
freeform_tags={
'EXAMPLE_KEY_N1B7f': 'EXAMPLE_VALUE_JVXXFfyI0yfTc8VhyM98'},
defined_tags={
'EXAMPLE_KEY_slbis': {
'EXAMPLE_KEY_jP0Ca': 'EXAMPLE--Value'}})],
display_name="EXAMPLE-displayName-Value",
fault_domain="EXAMPLE-faultDomain-Value",
volumes=[
oci.container_instances.models.CreateContainerEmptyDirVolumeDetails(
volume_type="EMPTYDIR",
name="EXAMPLE-name-Value",
backing_store="MEMORY")],
dns_config=oci.container_instances.models.CreateContainerDnsConfigDetails(
nameservers=["EXAMPLE--Value"],
searches=["EXAMPLE--Value"],
options=["EXAMPLE--Value"]),
graceful_shutdown_timeout_in_seconds=13,
image_pull_secrets=[
oci.container_instances.models.CreateVaultImagePullSecretDetails(
secret_type="VAULT",
registry_endpoint="EXAMPLE-registryEndpoint-Value",
secret_id="ocid1.test.oc1..<unique_ID>EXAMPLE-secretId-Value")],
container_restart_policy="ALWAYS",
freeform_tags={
'EXAMPLE_KEY_KtSXN': 'EXAMPLE_VALUE_jnqkd4eO0vZPdICNNXGP'},
defined_tags={
'EXAMPLE_KEY_PEjKo': {
'EXAMPLE_KEY_vVCsw': 'EXAMPLE--Value'}}),
opc_retry_token="EXAMPLE-opcRetryToken-Value",
opc_request_id="XOZNGN2Z7PW9JCCU8UXW<unique_ID>")
# Get the data from response
print(create_container_instance_response.data)