By Saied Kazemi, Software Engineer
It’s not news to anyone in IT that container technology has become one of the fastest growing areas of innovation. We’re excited about this trend and are continuously enhancing Google Cloud Platform (GCP) to make it a great place to run containers.
There are many great OSes available today for hosting containers, and we’re happy that customers have so many choices. Many people have told us that they’re also interested in using the same image that Google uses, even when they’re launching their own VMs, so they can benefit from all the optimizations that Google services receive.
Last spring, we released the beta version of Container-Optimized OS (formerly Container-VM Image), optimized for running containers on GCP. We use Container-Optimized OS to run some of our own production services (such as Google Cloud SQL, Google Container Engine, etc.) on GCP.
Today, we’re announcing the general availability of Container-Optimized OS. This means that if you’re a Compute Engine user, you can now run your Docker containers “out of the box” when you create a VM instance with Container-Optimized OS (see the end of this post for examples).
Container-Optimized OS represents the best practices we’ve learned over the past decade running containers at scale:
It’s easy to create a VM instance running Container-Optimized OS on Compute Engine. Either use the Google Cloud Console GUI or the gcloud command line tool as shown below:
gcloud compute instances create my-cos-instance --image-family cos-stable --image-project cos-cloud
Once the instance is created, you can run your container right away. For example, the following command runs an Nginx container in the instance just created:
gcloud compute ssh my-cos-instance -- "sudo docker run -p 80:80 nginx"
You can also log into your instance with the command:
gcloud compute ssh my_cos_instance --project my_project --zone us-east1-d
Here’s another simple example that uses Container Engine (which uses Container-Optimized OS as its OS) to run your containers. This example comes from the Google Container Engine Quickstart page.
gcloud container clusters create example-cluster kubectl run hello-node --image=gcr.io/google-samples/node-hello:1.0 --port=8080 kubectl expose deployment hello-node --type="LoadBalancer" kubectl get service hello-node curl 18.104.22.168:8080
We invite you to setup your own Container-Optimized OS instance and run your containers on it. Documentation for Container-Optimized OS is available here, and you can find the source code on the Chromium OS repository. We’d love to hear about your experience with Container-Optimized OS; you can reach us at StackOverflow with questions tagged google-container-os.