Creating a Service with Oracle Container Cloud Service

You can create a new service using the Oracle Container Cloud Service Container Console. The new service will comprise all of the necessary configuration for running a Docker container on a host, plus default deployment options.

To create a service using the Oracle Container Cloud Service Container Console:
  1. On the Services page of the Container Console, click New Service to display the Service Editor.
    Description of occs_services-list-3.png follows
    Description of the illustration occs_services-list-3.png
  2. Enter a unique name and a description for the new service. For example, Logstash.
    To make it easy to identify, you’ll often give the service the same name as the Docker image on which it’s based. But the service’s name doesn't have to be the same as the image’s name. However, note that the service name you enter initially is used from now on as the Service ID. You can’t change the Service ID once you’ve saved the service.
  3. Enter default orchestration properties for the service to specify how and where to deploy it, using the Scheduler, Availability, and Tag fields as follows:
    Option Use to specify:
    Scheduler How Oracle Container Cloud Service determines the order to use when selecting the hosts on which to start containers when you deploy the service:
    • Random: Oracle Container Cloud Service uses a random method to start containers evenly across the available hosts, regardless of memory or CPU availability.
    • Memory: Oracle Container Cloud Service starts containers on hosts in order, beginning with the host that has the greatest amount of available memory.

    • CPU: Oracle Container Cloud Service starts containers on hosts in order, beginning with the host that has the greatest amount of available CPU.

    If you don’t specify a value, Random is shown as the default when you deploy the service.
    Availability How Oracle Container Cloud Service determines where to start the number (N) of containers you specify when you deploy the service:
    • Per Pool: Oracle Container Cloud Service starts N containers across the resource pool as a whole, selecting hosts in order based on the setting of the Scheduler field.
    • Per Host: Oracle Container Cloud Service starts N containers on every host in the resource pool.

    • Per Tag: Oracle Container Cloud Service starts N containers on hosts assigned the tag in the Tag field, selecting hosts in order based on the setting of the Scheduler field.

    If you don’t specify a value, Per Pool is shown as the default when you deploy the service.

    If you expect to deploy a certain number of containers in the resource pool as a whole without worrying about which host they’re on:

    • Select per-pool (across hosts in this pool) from the Availability list.

    • From the Scheduler list, specify how Oracle Container Cloud Service determines which hosts to start the containers on.

    If you expect to deploy a certain number of containers on every host in the resource pool that has a particular tag associated with it:

    • Select per-tag (across hosts in this pool with a tag of...) from the Availability list.

    • Specify the tag to use to identify the hosts on which to deploy the service in the Tag field.

    • From the Scheduler list, specify how Oracle Container Cloud Service determines which hosts to start the containers on.

    If you expect to deploy a certain number of containers on every host in the resource pool, select per-host (on each host in this pool) from the Availability list.

    The default orchestration properties you specify are used as default values when deploying the service, but you can override them when you come to deploy the service.
  4. Optional: Define a health check to confirm that the service is running by clicking the Health Check Add button, entering a name for the health check, and a host port to poll. Now specify how Oracle Container Cloud Service is to check the service’s health:
    • use the Username and Password fields if you want Oracle Container Cloud Service to simply establish a basic authenticated HTTP connection with the host
    • use the Protocol, Interval, and Timeout fields if you want Oracle Container Cloud Service to perform more sophisticated health checks
    If the service fails a health check you’ve defined, Oracle Container Cloud Service displays an error message.

    Note:

    If you don’t define a health check for the service, Oracle Container Cloud Service determines the service’s status from the status of its container as reported by Docker Engine. If Docker Engine reports that the container is not running, Oracle Container Cloud Service will restart the container.
  5. Specify the Docker image to download for the service, the command to run to deploy the service, and values for other Docker runtime configuration options required to deploy the service, in the following ways:
    • Use the Builder tab to:
      • Specify the Docker image to use.

        How to specify the image depends on its location:

        • If the image is in the public Docker Hub registry, simply specify the image name and version (for example, nginx:latest)

        • If the image is in a private registry, prefix the image name and version with the registry name and username (for example, my.internalregistry.com/myusername/myapp:latest)

        • If the image is in a private hosted registry, prefix the image name and version with the registry name and username (for example, quay.io/myusername/nginx:latest)

      • Specify an optional custom command that the container is to run.

      • Pick service configuration options from the Available Options list and specify values for them (see Service Configuration Option Reference)

    • Use the Docker Run tab to enter a docker run command to launch the service (including values for service configuration options). This tab is handy if you already have a docker run command that you can cut and paste into the Docker Run tab. For example:
      docker run \
        -e="occs:availability=per-pool" \
        -e="occs:scheduler=cpu" \
        "karthequian/helloworld:latest"
    • Use the YAML tab to enter a YAML document to launch the service (including values for service configuration options). This tab is handy if you already have YAML code (for example, in a Docker Compose file) that you can cut and paste into the YAML tab. For example:
      version: 2
      services:
        my-helloworld-service:
          image: "karthequian/helloworld:latest"
          environment:
            - "occs:availability=per-pool"
            - "occs:scheduler=cpu"
    If you don’t include a registry when specifying the image to use, Oracle Container Cloud Service will attempt to pull the image from the Docker public registry.

    Tip:

    In most cases, it doesn’t matter whether you use the Builder tab, the Docker Run tab, the YAML tab, or a combination of all three. Changes you make in one tab are reflected in the other tabs. See Service Configuration Option Reference.

  6. Click Save.
The new service appears on the Services page. Having created the service, you’re now ready to deploy it (see Deploying a Service with Oracle Container Cloud Service) or add it to an application stack (see Creating a Stack).