This is a Docker volume plugin that uses gcsfuse
to
provision Google Cloud Storage buckets as Docker volumes.
Once this plugin is set up you can access files stored on Google Cloud Storage from inside a Docker container as follows:
# Obviously, $bucket must be the name of your bucket.
$ docker run -ti -v $bucket:/data --volume-driver=gcs ubuntu
or create the volume with
# to mount a specific object, use ${bucket_name}/${object_name}
$ docker volume create --driver=gcs --name=${bucket_name}/${object_name}
# or to mount a whole bucket, just specify it's name
$ docker volume create --driver=gcs --name=${bucket_name}
$ go get github.com/lorenzleutgeb/docker-volume-gcs
$ docker-volume-gcs [gcsfuse options] ROOT
The only argument for the plugin is the root directory to be used for mounts. It is mandatory and must be the last argument.
An example invocation would be
$ sudo docker-volume-gcs --key-file service-account.json --uid $UID --gid $GID --implicit-dirs /var/lib/docker/volumes/gcs
Currently, docker-volume-gcs
must be run as root user, because /run/docker/plugins
is usually owned by
root and it needs to create its socket there. gcsfuse
will complain about being run as root, and you
should pass --pid
and --gid
to avoid having everything owned by root.