[ Getting Started ] Deploying Container on GCE

Author/Charlie|Editor/Anni, Bonni

Are you wondering how to manage containers and managed instance groups in your familiar IaaS environment without costing extra resources or making repetitive steps of establishment over and over again? You can work with Docker Run, Docker Compose, Kubernetes, or simply choose a simpler and easier way by dropping the container image on GCE. After following our tutorial, you will find that deploying container on GCE only takes few minutes!

CREATE

icon/enlarge
  • Check Container, you will find Boot Disk automatically replaced with Container-Optimized OS.
  • Provide container image name: if it is not a public image, you can push it to GCS or Google Cloud Container Builder (Both require the Google Cloud SDK installed).

PUSHING YOUR IMAGE

$ docker build -t ///: -f ./Dockerfile .

#ex
$ docker build -t us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b -f ./Dockerfile .

The hostname of “gcr.io” can be decided according to the region.
  • us.gcr.io hosts your images in the United States
  • eu.gcr.io hosts your images in the European Union
  • asia.gcr.io hosts your images in Asia
  • gcr.io without a prefix hosts your images in the United States, but this behavior may change in a future release

PUSH

$ gcloud docker -- push <gsc_path>/<your_project_id>/<your_service_name>/<your_imahe_name>:<version>
 
#ex
$ gcloud docker -- push us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b</version></your_imahe_name></your_service_name></your_project_id></gsc_path>
 

CLOUD CONTAINER BUILDER

 
$ gcloud container builds submit -t <gsc_path>/<your_project_id>/<your_service_name>/<your_imahe_name>:<version> .
 
#ex
$ gcloud container builds submit -t us.gcr.io/hello-gcp/hello-gcp/myapp:0.1.13b .</version></your_imahe_name></your_service_name></your_project_id></gsc_path>

SET UP

icon/enlarge
  • Revise in accordance with your requirements (in the red box).
  • Check Run as privileged if you require -privileged, -cap-add or -cap-drop.
  • Get Started!

TIPS

  • In the above implementation, container and Host OS Port are one-to-one mapping. It doesn’t require additional setting.
  • Please set up your VPC network Firewall rules if it is public service.
  • All traffic of the instance will be forwarded to Host OS over the connection with SSH.
  • Docker can give commands to the container over the connection.
  • “Docker logs” is not available for now so you can use “Docker attach container-id” instead.
Subscribe to Our Newsletters

Grow Your Competitive Edge With Our Insights.