Hide
Google App Engine

Getting Started

Before you begin to use managed VMs, you'll need to install the Google Cloud SDK and Docker on your development machine. If you'd like to deploy an app into the Cloud, you'll also need to use the Google Developers Console to create a project and enable billing.

Install the Google Cloud SDK

  1. Download the Google Cloud SDK

  2. You must be authorized before you can use gcloud commands. Be sure that you've run gcloud auth login per the instructions.

  3. Install the gcloud app component, which supports gcloud's preview app options for managing App Engine development:

    gcloud components update app
    
  4. The --verbosity flag displays more detail in the command output. Using --verbosity debug can be extremely useful in tracking down problems. For example:

    $ gcloud --verbosity debug preview app run
    

Create a project and enable billing

In order to upload an application into the Cloud, you need to create a project and enable billing. If you prefer to try the tutorial using your local machine only, you can skip this step for now. (For a limited time, Google is offering a free trial with $300 you can use to explore managed VMs and the rest of the Cloud Platform.)

  1. You need a Google account to use the Developers Console. You've probably got one already, but if you don't, you'll be asked to create one the first time you visit the Developers Console

  2. If you have not yet created a billing account go the Billing page and create one.

  3. Return to the Projects page, and click Create Project. Be careful when you name your project. You'll be asked for a project name and also a project ID. The project name will appear in the Developers Console and can be changed at any time. The project ID is used in SDK commands and URLs to access to your app. It can never be changed. It's a good idea to specify your own project ID, rather than use the default value that appears in the create project form. (A project ID can have lowercase letters, digits or hyphens, and must start with a lowercase letter.)

  4. Go to your project's Billing and Settings page. Click Enable billing and select a billing account.

Install Docker

Managed VMs use Linux Containers to package your application, allowing you to build locally and then deploy to production App Engine. To enable this functionality the Cloud SDK relies on the Docker toolchain to configure and build the underlying container. To get started you will need to download and install Docker.

Select the tab that corresponds to your development environment:

Linux
Follow the instructions on the Docker site to install Docker for your flavor of Linux.

On non-Linux machines, the Docker install also includes a local virtual machine (called VirtualBox) and a lightweight utility called boot2docker to manage your running Docker environment. Installing boot2docker and the virtual machine environment will allow you to mimic the production environment locally. We recommend that you use boot2docker even on a Linux machine. Follow these steps:

First install VirtualBox if you do not already have it:

$ sudo apt-get install VirtualBox

Next download the latest boot2docker release and then start the daemon:

$ <path_to_download>/boot2docker-<version>-linux-<processor> init
$ <path_to_download>/boot2docker-<version>-linux-<processor> up

The Cloud SDK uses the DOCKER_HOST, DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables to connect to your Docker installation. You can use the boot2docker command to set these variables:

$ $(boot2docker shellinit)

Mac

Follow the instructions on the Docker site to install Docker for Mac OS X

Installing Docker will also install a local virtual machine and a lightweight utility called boot2docker to manage your running Docker environment. Installing boot2docker and the virtual machine environment will allow you to mimic the production environment locally.

The Cloud SDK uses the DOCKER_HOST, DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables to connect to your Docker installation. You can use the boot2docker command to set these variables:

$ $(boot2docker shellinit)

Windows

Follow the instructions on the Docker site to install Docker for Windows

After installing, perform these additional steps:

  1. Select the MSYS-git UNIX tools component when installing Docker.

  2. Add the MSYS-git UNIX tools component to your path:

    1. Right click Start > Computer > Advanced System Settings > Environment Variables.
    2. Edit Path in the environment settings form, and add ;C:\Program Files (x86)\Git\bin at the end of the Variable value field.

The Cloud SDK uses the DOCKER_HOST, DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables to connect to your Docker installation. You must set these variables manually on Windows:

  1. Run boot2docker shellinit to see the correct values:

    boot2docker shellinit
    

    They will appear at the end of the output in lines that look like this:

    export DOCKER_HOST=tcp://192.168.59.103:2376
    export DOCKER_CERT_PATH=C:\Users\USER\.boot2docker\certs\boot2docker-vm
    export DOCKER_TLS_VERIFY=1
    
  2. Execute a set command for each exported variable, copying the exported value:

    set DOCKER_HOST=tcp://192.168.59.103:2376
    set DOCKER_CERT_PATH=C:/Users/USER/.boot2docker/certs/boot2docker-vm
    set DOCKER_TLS_VERIFY=1
    

Note that in the set command, the path separator character for DOCKER_CERT_PATH is the / character.

Check your Docker versions

The Docker instructions will always install the latest version of Docker. You can verify what version of Docker you are running by typing:

$ boot2docker version

You should be running version 1.4.1 or higher.

Your local Docker environment contains a Docker client and a server. They must be in sync with each other. When they are not, boot2docker commands return various kinds of errors. If you've installed Docker over an older installation, you can run these commands to be sure you've got a clean setup:

$ boot2docker stop
$ boot2docker delete
$ boot2docker download
$ boot2docker init
$ boot2docker start
$ $(boot2docker shellinit)

Use the boot2docker status command to see the status of your local VM:

$ boot2docker status

This docker command shows the processes running in your VM (there should be none upon startup):

$ docker ps

Note to Java Developers

If you are using boot2docker installed by Docker, the default 1Gb memory in the boot2docker VM is not enough for running Java apps locally. You must increase it to at least 2 Gb.

From the VirtualBox UI:

  • stop running the VM
  • go to System
  • increase Base Memory
  • click OK
  • restart the VM

You can also use these VirtualBox commands:

$ VBoxManage controlvm "boot2docker-vm" poweroff
$ VBoxManage modifyvm "boot2docker-vm" --memory "2048"

Preload the standard runtime images

This step is optional. If you plan to develop using the Java, Python, or Go standard runtimes, the required docker images will be downloaded the first time you deploy your code or test it locally. This can take some time. You can pre-fetch these images using this command:

$ gcloud preview app setup-managed-vms

Use the docker images command to see the images you've got:

$ docker images

Tutorial

The tutorial demonstrates how to run a program in a managed VM hosting environment, and how to extend a Dockerfile to provide more capabilities in your runtime environment.

Sample Projects

Try running one of our sample projects:

Standard Runtimes

Most of these examples show how to add commands to the default Dockerfile that is automatically generated for each standard runtime.

Python

Go

Java

All of the Java examples use the special Maven extras for managed VMs.

Custom Runtimes

These samples show how managed VMs can support App Engine applications written in other languages, and with custom software stacks.

Node.js

nginx

Dart