Working with Container Instances
This section describes how to create a container instance, view information about container instances and their containers, update the name and tags of a container instance, and delete a container instance. You can stop, start, and restart a container instance and move a container instance to a new compartment. Creating a container instance creates a container in the instance.
Creating a Container Instance
A Private Cloud Appliance container instance includes a single container.
The following is the minimum information that you must provide to create a container instance:
-
The compartment where you want to create the container instance
-
The shape
-
The VCN and subnet
Container instances leverage 15 GB of ephemeral storage that is shared between the container instance and the container. This ephemeral storage is created automatically when the container instance is created. You cannot manually create storage and attach it to the container instance.
Using the Compute Web UI
-
On the dashboard, select Containers / Container Instances.
-
Select the Create Container Instance button above the Container Instances list.
-
In the Create Container Instance dialog, enter the following information:
-
Name: Enter a name for the container instance. Instance names have the following characteristics:
-
Can be changed after the container instance is created.
-
Do not need to be unique.
-
Can contain only alphanumeric characters and the hyphen (-) character.
-
Can be a maximum of 63 characters.
-
-
General Information
-
Create in Compartment: Select the compartment where you want to create the container instance.
-
Fault Domain: (Optional) Select a fault domain. By default, the system automatically selects the best fault domain for the container instance when the instance is created. If you specify a fault domain, and the requested fault domain cannot accommodate the container instance, instance create fails. The fault domain can be changed after the container instance is created.
-
-
Shape: Select either the CI.Standard.x86.Generic shape or the CI.Standard.E5.Flex shape. For descriptions of these shapes, see Container Instances in the Oracle Private Cloud Appliance Concepts Guide.
Use the sliders to specify the number of OCPUs you want, and the total amount of memory you want in gigabytes.
-
VNIC
-
Name: Enter the name of the VNIC. By default, the container instance name is used.
-
Networking
-
Private IP: (Optional) Enter the private IP address to use.
-
Hostname: (Optional) Enter a hostname if you are using DNS within the cloud network. The hostname must be unique across all VNICs in the subnet. By default, the container instance name is used for the hostname.
-
Assign Public IP: The box is checked by default. Uncheck the box if you do not want a public IP address to be assigned to this container instance.
-
-
Subnet
-
VCN: Select a VCN from the list. You might need to change the compartment to the compartment where the VCN is located.
-
Subnet: Select a subnet from the list.
-
-
-
Container Image URL: Enter the URL of the image to use to launch the container instance. Specify a container image from an external registry of your choice. The image must be signed by a well known Certificate Authority, and the image manifest must be an up-to-date version.
-
Tagging: (Optional) Add defined or free-form tags for this instance as described in Adding Tags at Resource Creation. Tags can also be applied later.
-
-
Select the Create Container Instance button in the dialog.
The instance details page is displayed. On the Container Instance Information tab, the Shape Configuration section shows the shape, the number of OCPUs, the network bandwidth, and the total memory. The Primary VNIC column shows the VCN and subnet, the primary private IP address and any assigned public IP address, and the MAC address.
To check the status of the container instance create, scroll to the Resources section and select Work Request(s).
Select Containers in the Resources section. The container is named
computecontainer-unique_ID
. See Working with Containers in Container Instances.
Using the OCI CLI
-
Get the following information:
-
The OCID of the compartment where you want to create the container instance:
oci iam compartment list
-
The name of the shape to use. Use the following command to list the available shapes and their characteristics. Use the OCID of the compartment where you want to create the instance. For descriptions of these shapes, see Container Instances in the Oracle Private Cloud Appliance Concepts Guide.
$ oci container-instances container-instance list-shapes --compartment-id compartment_OCID
You must also specify the shape configuration, as shown in the following example. You must provide a value for
ocpus
, and you can specify thememoryInGBs
.--shape-config '{"ocpus": 2, "memoryInGBs": 2}'
-
The URL of the image to use to launch the container instance. Specify a container image from an external registry of your choice. The image must be signed by a well known Certificate Authority, and the image manifest must be an up-to-date version.
-
-
Construct an argument for the
--vnics
option.This is a list of the networks available to the container on this container instance. For each VNIC, provide the name of the VNIC, the OCID of the subnet that you want to use, the private IP address, and whether a public IP address should be assigned.
Use the following command to show the syntax for this argument:
$ oci container-instances container-instance create --generate-param-json-input vnics
-
Run the create container instance command.
Syntax:
Only the required parameters are shown.
oci container-instances container-instance create --availability-domain AD-1 \ --compartment-id compartment_OCID --containers '[{"imageUrl": "image_url"}]' \ --shape shape --shape-config '{"ocpus": 2}' \ --vnics file://network_cofig.json
Example:
If you set a display name for the container instance, see the Compute Web UI procedure for characteristics.
For a complete list of required and optional parameters, use the following command:
$ oci compute instance launch -h
$ oci container-instances container-instance create --availability-domain AD-1 \ --compartment-id ocid1.compartment.unique_ID --containers file://container_config.json \ --shape CI.Standard.E5.Flex --shape-config '{"ocpus": 2,"memoryInGBs": 2}' \ --vnics '[{"subnetId": "ocid1.subnet.unique_ID"}]'
View the work request to monitor the status of the container instance create. The work request OCID is returned in the container instance create output.
$ oci container-instances work-request get --work-request-id ocid1.workrequest.unique_ID
If the status of the container instance create is Failed, list the errors reported in the work request:
$ oci container-instances work-request list-errors --work-request-id ocid1.workrequest.unique_ID
Viewing Container Instances
This topic describes how to list all container instances in a compartment and how to view more information about a specified container instance.
Using the Compute Web UI
-
On the dashboard, select Containers / Container Instances.
If the container instance that you want to view is not listed, use the Compartment drop-down menu above the container instances list to select the correct compartment.
-
To view more information about the container instance, select the name of the container instance in the list.
The container instance details page is displayed.
-
On the container instance details page, scroll to the Resources section, and select Containers to view information about the container instance container.
Using the OCI CLI
-
List all container instances in a specified compartment.
-
Get the OCID of the compartment where you want to list container instances:
oci iam compartment list
-
Run the list container instances command.
$ oci container-instances container-instance list --compartment-id ocid1.compartment.unique_ID
Add the
--display-name
option to list only container instances with the specified name. Recall that container instance names do not need to be unique.
-
-
Get more information about a specific container instance.
-
Get the OCID of the container instance from the
container-instance list
command. -
Run the get container instance command.
$ oci container-instances container-instance get --container-instance-id ocid1.container-instance.unique_ID
-
Updating a Container Instance
You can change the name and tags of a specified container instance.
Using the Compute Web UI
-
On the dashboard, select Containers / Container Instances.
If the container instance that you want to update is not listed, use the Compartment drop-down menu above the container instances list to select the correct compartment.
-
In the container instances list, for the container instance that you want to update, select the Actions menu and select Edit.
-
When you are finished making your changes, select the Save Changes button.
Using the OCI CLI
-
Get the OCID of the container instance that you want to update:
oci container-instances container-instance list
-
Run the update container instance command.
Example:
$ oci container-instances container-instance update --container-instance-id ocid1.container-instance.unique_ID \ --display-name new_name --defined-tags new_tags --force
Moving a Container Instance to a Different Compartment
This topic describes how to move a container instance to a new compartment within the same tenancy. To move a container instance, you must use the OCI CLI.
Using the OCI CLI
-
Get the OCID of the container instance that you want to move:
oci container-instances container-instance list
-
Run the move container instance command.
Example:
$ oci container-instances container-instance change-compartment --container-instance-id ocid1.container-instance.unique_ID \ --compartment-id ocid1.compartment.unique_ID
Stopping, Starting, and Restarting a Container Instance
This topic describes how to start, stop, and restart a container instance.
You can start a container instance that is in the Inactive state. You can stop a container instance that is in the Active state.
Using the Compute Web UI
-
On the dashboard, select Containers / Container Instances.
If the container instance that you want to start, stop, or restart is not listed, use the Compartment drop-down menu above the container instances list to select the correct compartment.
-
For the container instance that you want to start, stop, or restart, select the Actions menu, and select the Start, Stop, or Restart option.
Alternatively, in the container instance list, select the name of the container instance to display the details page for that container instance. Select the Controls menu, and select the Start, Stop, or Restart option.
-
Select the Start Container Instance, Stop Container Instance, or Restart Container Instance button on the confirmation dialog.
In the Resources section of the container instance details page, select Work Request(s) to check the status of the container instance start, stop, or restart.
Using the OCI CLI
-
Get the OCID of the container instance that you want to stop, start, or restart:
oci container-instances container-instance list
-
Start, stop, or restart the container instance.
-
Start the container instance if it is "Inactive."
$ oci container-instances container-instance start --container-instance-id ocid1.container-instance.unique_ID
-
Stop the container instance if it is "Active."
$ oci container-instances container-instance stop --container-instance-id ocid1.container-instance.unique_ID
-
Restart the container instance.
$ oci container-instances container-instance restart --container-instance-id ocid1.container-instance.unique_ID
-
Deleting a Container Instance
You can permanently delete container instances that you no longer need. Any attached VNICs are automatically detached when the container instance is deleted. Eventually, the container instance's public and private IP addresses are released and become available for other container instances. When the containers are deleted by the service, any data on the ephemeral storage is lost.
Using the Compute Web UI
-
On the dashboard, select Containers / Container Instances.
If the container instance that you want to delete is not listed, use the Compartment drop-down menu above the container instances list to select the correct compartment.
-
For the container instance that you want to delete, click the Actions menu, and click the Delete option.
Alternatively, in the container instance list, click the name of the container instance to display the details page for that container instance. Click the Controls menu, and click the Delete option.
-
On the confirm container instance delete dialog, select the Confirm button.
Select Work Request(s) in the Resources box to check the status of the container instance delete. Deleted container instances temporarily remain in the list of container instances with the state Deleted.
Using the OCI CLI
-
Get the OCID of the container instance that you want to delete:
oci container-instances container-instance list
-
Run the delete container instance command.
$ oci container-instances container-instance delete --container-instance-id ocid1.container-instance.unique_ID
View the work request to monitor the status of the container instance delete. The work request OCID is returned in the container instance delete output.
$ oci container-instances work-request get --work-request-id ocid1.workrequest.unique_ID