mcuadros / gce-docker

Google Cloud Engine integration for Docker
MIT License
59 stars 13 forks source link

Google Cloud Engine integration for Docker Build Status

gce-docker is a service that provides integration with the GCE to Docker, the following resources are supported:

Examples

Creating a Persistent Disk and mount is a volume to a Container

docker run -ti -v my-disk:/data --volume-driver=gce busybox df -h /data

Creating a simple Load Balancer with a static IP

docker run -d --label gce.lb.address=104.197.200.230 --label gce.lb.type=static -p 80:80 tutum/hello-world

Installing

The recommended way to install gce-docker is use the provided docker image.

Run the driver using the following command:

docker run -d -v /:/rootfs -v /run/docker/plugins:/run/docker/plugins -v /var/run/docker.sock:/var/run/docker.sock --privileged mcuadros/gce-docker

privileged is required since gce-docker needs low level access to the host mount namespace, the driver mounts, umounts and format disk.

The instance requires Read/Write privileges to Google Compute Engine and IP forwarding flags should be active to.

Usage

Persistent Disks

Persistent disk creation

Using docker volume create a new disk is created.

docker volume create --driver=gce --name my-disk -o SizeGb=90

Options:

Using a disk on your container

Just add the flags --volume-driver=gce and the -v <disk-name>:/data to any docker run command:

docker run -ti -v my-disk:/data --volume-driver=gce busybox sh

If the disk already exists will be used, if not a new one with the default values will be created (Standard/500GB)

The disk is attached to the instance, if the disk is not formatted also is formatted with ext4, when the container stops, the disk is unmounted and detached.

Load Balancer

The load balancers, are handle by a watcher, waiting for Docker events, the watched events are start and die. When a new containeris created or destroyed, the LoadBalancer and all the others dependant resources are created or deleted too.

This is a small example create a LoadBalancer for a web server:

docker run -d --label gce.lb.type=ephemeral -p 80:80 tutum/hello-world

Available labels:

License

MIT, see LICENSE