In an earlier article, I discussed the creation of a generic Docker Container Image that runs any Node.JS application based on sources for that application on GitHub. When the container is started, the GitHub URL is passed in as a parameter and the container will download the sources and run the application. Using this generic image, you can your Node application everywhere you can run a Docker container. One of the places where you can run a Docker Container is the Oracle Container Cloud Service (OCCS) – a service that offers a platform for managing your container landscape. In this article, I will show how I used OCCS to run my generic Docker image for running Node application and how I configured the service to run a specific Node application from GitHub.
Getting started with OCCS is described very well in an article by my colleague Luc Gorissen on this same blog: Docker, WebLogic Image on Oracle Container Cloud Service. I used his article to get started myself.
The steps are:
- create OCCS Service instance
- configure OCCS instance (with Docker container image registry)
- Create a Service for the desired container image (the generic Node application runner) – this includes configuring the Docker container parameters such as port mapping and environment variables
- Deploy the Service (run a container instance)
- Check the deployment (status, logs, assigned public IP)
- Test the deployment – check if the Node application is indeed available
Create OCCS Service instance
Assuming you have an Oracle Public Cloud account with a subscription to OCCS. Go to the Dashboard for OCCS. Click on Create Service
Configure the service instance:
However, do not make it too small (!) (Oracle Cloud does not come in small portions):
So now with the minimum allowed data volume size (for a stateless container!)
This time I pass the validations:
And the Container Cloud Service instance is created:
Configure OCCS instance (with Docker container image registry)
After some time, when the instance is ready, I can access it:
It is pretty sizable as you can see.
Let’s access the Container console.
The Dashboard gives an overview of the current status, the actual deployments (none yet) and access to Services, Stacks, Containers, Images and more.
One of the first things to do, is to configure a (Container Image) Registry – for example a local registry or an account on Docker Hub – my account, where I have saved container images that I need to create containers from in the Oracle Container Cloud:
My details are validated:
The registry is added:
Create a Service for a desired container image
Services are container images along with configuration to be used for running containers. Oracle Container Cloud comes with a number of popular container images already configured as services. I want to add another service, for my own image: the generic Node application runner). For this I select the image from my Docker Hub account followed by configuring the Docker container parameters such as port mapping and environment variables
The Service editor – the form to define the Image (from one of the configured registries), the name of the service (which represents the combination of the image with a set of configuration settings to make it into a specific service) and of course those configuration settings – port mappings, environment variables, volumes etc.
Note: I am creating a service for the image that can run any Node application that is available in GitHub (as described here: https://technology.amis.nl/2017/05/21/running-node-js-applications-from-github-in-generic-docker-container/ )
Deploy the Service (run a container instance)
After the service was created, it is now available as the blueprint to run new containers from. This dis done through a Deployment – this ties together a Service with a some runtime settings around scaling, load balancing and the like:
Set the deployment details for the new deployment of this service:
After completing these details, press deploy to go ahead and run the new deployment; in this case it consists of a single instance (boring….) but it could have been more involved.
The deployment is still starting.
A little later (a few seconds) the container is running:
Check some details:
To check the deployment (status, logs, assigned IP), click on the container name:
Anything written to the console inside the container is accessible from the Logs:
To learn about the public IP address at which the application is exposed, we need to turn to the Hosts tab.
Monitor Hosts
Drill down on one specific host:
and learn its public IP address, where we can access the application running in the deployed container.
Test the deployment – check if the Node application is indeed available
With the host’s public IP address and the knowledge that port 8080 inside the container (remember environment variable APP_PORT that was defined as 8080 to pass to the generic Node application running) is mapped to port 8005 externally, we can now invoke the application running inside the container deployed on the Container Cloud Service from our local browser.
And there is the output of the application (I never said it would be spectacular…)
Conclusion
After having gotten used to the sequence of actions:
- configure registry (probably only once)
- configure a service (for every container image plus specific setup of configuration parameters, including typical Docker container settings such as port mapping, volumes, environment variables)
- define and run a deployment (from a service) with scaling factor and other deployment details
- get hold of host public IP address to access the application in the container
Oracle Container Cloud Service provides a very smooth experience that compares favorably with other Container Cloud Services and management environments I have seen. From a Developer’s perspective at least, OCCS does a great job. It is a little too early to say much about the Ops side of things – how operations with OCCS are.