Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run private docker images on Google Container Engine

How do I run a docker image that I built locally on Google Container Engine?

like image 958
proppy Avatar asked Nov 06 '14 20:11

proppy


People also ask

How do you run a Docker container image on a Google?

Under Container, select Deploy container image. Under Container image, specify the Docker image name and configure options to run the container if desired. For example, you can specify gcr.io/cloud-marketplace/google/nginx1:15 for the container image. Click Create.

How do I access private Docker images?

Navigate to Docker Hub create a Docker ID and select the personal subscription. Using docker login from the CLI, sign in using your original Docker ID and pull your private images.

Can Docker images be private?

Private Docker repositories provide restricted access to the images that they contain. Unlike public repositories, only authorized users can access the images. This way, it's possible to allow access only to a specific group of users, like organizations, teams, or even a single person.


2 Answers

You can push your image to Google Container Registry and reference them from your pod manifest.

Detailed instructions

Assuming you have a DOCKER_HOST properly setup , a GKE cluster running the last version of Kubernetes and Google Cloud SDK installed.

  1. Setup some environment variables

    gcloud components update kubectl gcloud config set project <your-project> gcloud config set compute/zone <your-cluster-zone> gcloud config set container/cluster <your-cluster-name> gcloud container clusters get-credentials <your-cluster-name> 
  2. Tag your image

    docker tag <your-image> gcr.io/<your-project>/<your-image> 
  3. Push your image

    gcloud docker push gcr.io/<your-project>/<your-image> 
  4. Create a pod manifest for your container: my-pod.yaml

    id: my-pod kind: Pod apiVersion: v1 desiredState:   manifest:     containers:     - name: <container-name>       image: gcr.io/<your-project>/<your-image>     ... 
  5. Schedule this pod

    kubectl create -f my-pod.yaml 
  6. Repeat from step (4) for each pod you want to run. You can have multiple definitions in a single file using a line with --- as delimiter.

like image 143
13 revs, 4 users 93% Avatar answered Sep 28 '22 04:09

13 revs, 4 users 93%


The setup I use is to deploy my own docker registry combined with ssh port forwarding. For that purpose I set up a ssh server in the cluster and use ~/.ssh/config to configure a port forward to the registry.

Also I use jenkins to build the images right in the cloud.

like image 26
ruediste Avatar answered Sep 28 '22 03:09

ruediste