2015-06-08 00:58:53 +00:00
<!-- [metadata]>
+++
2015-08-26 18:08:13 +00:00
title = "Storage Drivers"
description = "Explains how to use storage drivers"
keywords = ["registry, on-prem, images, tags, repository, distribution, storage drivers, advanced"]
2015-12-03 11:11:10 +00:00
aliases = ["/registry/storage-drivers/"]
2015-06-08 00:58:53 +00:00
[menu.main]
parent="smn_registry_ref"
+++
<![end-metadata]-->
2015-04-29 19:20:09 +00:00
# Docker Registry Storage Driver
2015-03-03 07:33:02 +00:00
2015-03-06 01:23:33 +00:00
This document describes the registry storage driver model, implementation, and explains how to contribute new storage drivers.
2015-04-28 22:10:52 +00:00
## Provided Drivers
2015-03-06 01:23:33 +00:00
2015-03-06 01:26:50 +00:00
This storage driver package comes bundled with several drivers:
2015-03-06 01:23:33 +00:00
2015-04-20 07:41:32 +00:00
- [inmemory ](storage-drivers/inmemory.md ): A temporary storage driver using a local inmemory map. This exists solely for reference and testing.
- [filesystem ](storage-drivers/filesystem.md ): A local storage driver configured to use a directory tree in the local filesystem.
- [s3 ](storage-drivers/s3.md ): A driver storing objects in an Amazon Simple Storage Solution (S3) bucket.
- [azure ](storage-drivers/azure.md ): A driver storing objects in [Microsoft Azure Blob Storage ](http://azure.microsoft.com/en-us/services/storage/ ).
2015-04-23 16:13:52 +00:00
- [rados ](storage-drivers/rados.md ): A driver storing objects in a [Ceph Object Storage ](http://ceph.com/docs/master/rados/ ) pool.
2015-05-29 13:34:47 +00:00
- [swift ](storage-drivers/swift.md ): A driver storing objects in [Openstack Swift ](http://docs.openstack.org/developer/swift/ ).
2015-07-31 04:43:04 +00:00
- [oss ](storage-drivers/oss.md ): A driver storing objects in [Aliyun OSS ](http://www.aliyun.com/product/oss ).
2015-07-20 17:45:15 +00:00
- [gcs ](storage-drivers/gcs.md ): A driver storing objects in a [Google Cloud Storage ](https://cloud.google.com/storage/ ) bucket.
2015-03-06 01:23:33 +00:00
2015-04-28 22:10:52 +00:00
## Storage Driver API
2015-03-06 01:23:33 +00:00
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.
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.
2015-06-29 23:39:45 +00:00
Storage drivers are intended to be written in Go, providing compile-time
validation of the `storagedriver.StorageDriver` interface.
2015-03-06 01:23:33 +00:00
2015-04-28 22:10:52 +00:00
## Driver Selection and Configuration
2015-03-06 01:23:33 +00:00
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.
2015-06-29 23:39:45 +00:00
Storage driver factories may be registered by name using the
`factory.Register` method, and then later invoked by calling `factory.Create`
with a driver name and parameters map. If no such storage driver can be found,
`factory.Create` will return an `InvalidStorageDriverError` .
2015-03-06 01:23:33 +00:00
2015-04-28 22:10:52 +00:00
## Driver Contribution
2015-03-06 01:23:33 +00:00
2015-04-28 22:10:52 +00:00
### Writing new storage drivers
2015-08-26 18:08:13 +00:00
2015-06-29 23:39:45 +00:00
To create a valid storage driver, one must implement the
`storagedriver.StorageDriver` interface and make sure to expose this driver
via the factory system.
2015-03-06 01:23:33 +00:00
2015-06-29 23:39:45 +00:00
#### Registering
2015-08-26 18:08:13 +00:00
2015-03-06 01:23:33 +00:00
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.
## Testing
2015-08-26 18:08:13 +00:00
2015-06-29 23:39:45 +00:00
Storage driver test suites are provided in
`storagedriver/testsuites/testsuites.go` and may be used for any storage
driver written in Go. Tests can be registered using the `RegisterSuite`
function, which run the same set of tests for any registered drivers.