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
-
Download the Google Cloud SDK
-
You must be authorized before you can use
gcloudcommands. Be sure that you've rungcloud auth loginper the instructions. -
Install the gcloud app component, which supports gcloud's
preview appoptions for managing App Engine development:gcloud components update app -
The
--verbosityflag displays more detail in the command output. Using--verbosity debugcan 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.)
-
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
-
If you have not yet created a billing account go the Billing page and create one.
-
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.)
-
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:
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)
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)
Follow the instructions on the Docker site to install Docker for Windows
After installing, perform these additional steps:
-
Select the MSYS-git UNIX tools component when installing Docker.
-
Add the MSYS-git UNIX tools component to your path:
- Right click Start > Computer > Advanced System Settings > Environment Variables.
- Edit Path in the environment settings form, and add
;C:\Program Files (x86)\Git\binat 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:
-
Run
boot2docker shellinitto see the correct values:boot2docker shellinitThey 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 -
Execute a
setcommand 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
- Python Hello World Quickstart
- Fortunespeak
- SQLite guestbook
- Zombie Apocalypse Simulator
- Sudoku Solver
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
- Todos
- Node.js QuickStart This app includes a utility library for accessing App Engine services
nginx
Dart
- The Dart documentation shows how to deploy a Dart application using managed VMs