gce-docker is a service that provides integration with the GCE to Docker, the following resources are supported:
docker run -ti -v my-disk:/data --volume-driver=gce busybox df -h /data
docker run -d --label gce.lb.address=104.197.200.230 --label gce.lb.type=static -p 80:80 tutum/hello-world
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.
Using docker volume create
a new disk is created.
docker volume create --driver=gce --name my-disk -o SizeGb=90
Options:
pd-ssd
or pd-standard
): Disk type to use to create the disk.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.
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:
ephemeral
or static
): Type of IP to be used in the new load balancerstatic
): Value of the reserved IP address that the forwarding rule is serving on behalf of. The IP address or the IP name.NONE
: Connections from the same client IP may go to any instance in the pool.CLIENT_IP
: Connections from the same client IP will go to the same instance in the pool while that instance remains healthy.CLIENT_IP_PROTO
: Connections from the same client IP with the same IP protocol will go to the same instance in the pool while that instance remains healthy.MIT, see LICENSE