github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/docs/storagedrivers.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Storage Drivers" 4 description = "Explains how to use storage drivers" 5 keywords = ["registry, on-prem, images, tags, repository, distribution, storage drivers, advanced"] 6 aliases = ["/registry/storage-drivers/"] 7 [menu.main] 8 parent="smn_registry_ref" 9 +++ 10 <![end-metadata]--> 11 12 13 # Docker Registry Storage Driver 14 15 This document describes the registry storage driver model, implementation, and explains how to contribute new storage drivers. 16 17 ## Provided Drivers 18 19 This storage driver package comes bundled with several drivers: 20 21 - [inmemory](storage-drivers/inmemory.md): A temporary storage driver using a local inmemory map. This exists solely for reference and testing. 22 - [filesystem](storage-drivers/filesystem.md): A local storage driver configured to use a directory tree in the local filesystem. 23 - [s3](storage-drivers/s3.md): A driver storing objects in an Amazon Simple Storage Solution (S3) bucket. 24 - [azure](storage-drivers/azure.md): A driver storing objects in [Microsoft Azure Blob Storage](http://azure.microsoft.com/en-us/services/storage/). 25 - [rados](storage-drivers/rados.md): A driver storing objects in a [Ceph Object Storage](http://ceph.com/docs/master/rados/) pool. 26 - [swift](storage-drivers/swift.md): A driver storing objects in [Openstack Swift](http://docs.openstack.org/developer/swift/). 27 - [oss](storage-drivers/oss.md): A driver storing objects in [Aliyun OSS](http://www.aliyun.com/product/oss). 28 - [gcs](storage-drivers/gcs.md): A driver storing objects in a [Google Cloud Storage](https://cloud.google.com/storage/) bucket. 29 30 ## Storage Driver API 31 32 The storage driver API is designed to model a filesystem-like key/value storage in a manner abstract enough to support a range of drivers from the local filesystem to Amazon S3 or other distributed object storage systems. 33 34 Storage drivers are required to implement the `storagedriver.StorageDriver` interface provided in `storagedriver.go`, which includes methods for reading, writing, and deleting content, as well as listing child objects of a specified prefix key. 35 36 Storage drivers are intended to be written in Go, providing compile-time 37 validation of the `storagedriver.StorageDriver` interface. 38 39 ## Driver Selection and Configuration 40 41 The preferred method of selecting a storage driver is using the `StorageDriverFactory` interface in the `storagedriver/factory` package. These factories provide a common interface for constructing storage drivers with a parameters map. The factory model is based off of the [Register](http://golang.org/pkg/database/sql/#Register) and [Open](http://golang.org/pkg/database/sql/#Open) methods in the builtin [database/sql](http://golang.org/pkg/database/sql) package. 42 43 Storage driver factories may be registered by name using the 44 `factory.Register` method, and then later invoked by calling `factory.Create` 45 with a driver name and parameters map. If no such storage driver can be found, 46 `factory.Create` will return an `InvalidStorageDriverError`. 47 48 ## Driver Contribution 49 50 ### Writing new storage drivers 51 52 To create a valid storage driver, one must implement the 53 `storagedriver.StorageDriver` interface and make sure to expose this driver 54 via the factory system. 55 56 #### Registering 57 58 Storage drivers should call `factory.Register` with their driver name in an `init` method, allowing callers of `factory.New` to construct instances of this driver without requiring modification of imports throughout the codebase. 59 60 ## Testing 61 62 Storage driver test suites are provided in 63 `storagedriver/testsuites/testsuites.go` and may be used for any storage 64 driver written in Go. Tests can be registered using the `RegisterSuite` 65 function, which run the same set of tests for any registered drivers.