1
0
mirror of https://github.com/distribution/distribution synced 2024-11-06 19:35:52 +01:00

Merge pull request #617 from dmp42/pathchange

Saner default data location
This commit is contained in:
Stephen Day 2015-06-11 11:42:24 -07:00
commit a5b21fa8f0
6 changed files with 44 additions and 21 deletions

@ -22,7 +22,7 @@ storage:
cache: cache:
blobdescriptor: redis blobdescriptor: redis
filesystem: filesystem:
rootdirectory: /tmp/registry-dev rootdirectory: /var/lib/registry
maintenance: maintenance:
uploadpurging: uploadpurging:
enabled: false enabled: false

@ -12,7 +12,17 @@ If a Go development environment is setup, one can use `go get` to install the
go get github.com/docker/distribution/cmd/registry go get github.com/docker/distribution/cmd/registry
``` ```
The above will install the source repository into the `GOPATH`. The `registry` The above will install the source repository into the `GOPATH`.
Now create the directory for the registry data (this might require you to set permissions properly)
```sh
mkdir -p /var/lib/registry
```
... or alternatively `export REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/somewhere` if you want to store data into another location.
The `registry`
binary can then be run with the following: binary can then be run with the following:
``` ```

@ -21,16 +21,16 @@ configure the `rootdirectory` of the `filesystem` storage backend:
``` ```
storage: storage:
filesystem: filesystem:
rootdirectory: /tmp/registry-dev rootdirectory: /var/lib/registry
``` ```
To override this value, set an environment variable like this: To override this value, set an environment variable like this:
``` ```
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/tmp/registry/test REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/somewhere
``` ```
This variable overrides the `/tmp/registry-dev` value to the `/tmp/registry/test` This variable overrides the `/var/lib/registry` value to the `/somewhere`
directory. directory.
>**Note**: If an environment variable changes a map value into a string, such >**Note**: If an environment variable changes a map value into a string, such
@ -72,7 +72,7 @@ log:
loglevel: debug # deprecated: use "log" loglevel: debug # deprecated: use "log"
storage: storage:
filesystem: filesystem:
rootdirectory: /tmp/registry-dev rootdirectory: /var/lib/registry
azure: azure:
accountname: accountname accountname: accountname
accountkey: base64encodedaccountkey accountkey: base64encodedaccountkey
@ -284,7 +284,7 @@ Permitted values are `error`, `warn`, `info` and `debug`. The default is
```yaml ```yaml
storage: storage:
filesystem: filesystem:
rootdirectory: /tmp/registry rootdirectory: /var/lib/registry
azure: azure:
accountname: accountname accountname: accountname
accountkey: base64encodedaccountkey accountkey: base64encodedaccountkey
@ -1342,7 +1342,7 @@ log:
level: debug level: debug
storage: storage:
filesystem: filesystem:
rootdirectory: /tmp/registry-dev rootdirectory: /var/lib/registry
http: http:
addr: localhost:5000 addr: localhost:5000
secret: asecretforlocaldevelopment secret: asecretforlocaldevelopment
@ -1352,7 +1352,7 @@ http:
The above configures the registry instance to run on port `5000`, binding to The above configures the registry instance to run on port `5000`, binding to
`localhost`, with the `debug` server enabled. Registry data storage is in the `localhost`, with the `debug` server enabled. Registry data storage is in the
`/tmp/registry-dev` directory. Logging is in `debug` mode, which is the most `/var/lib/registry` directory. Logging is in `debug` mode, which is the most
verbose. verbose.
A similar simple configuration is available at A similar simple configuration is available at

@ -8,16 +8,11 @@ IGNORES-->
You obviously need to [install Docker](https://docs.docker.com/installation/) (remember you need **Docker version 1.6.0 or newer**). You obviously need to [install Docker](https://docs.docker.com/installation/) (remember you need **Docker version 1.6.0 or newer**).
## Getting started in 2 lines ## Getting started
Create a folder for your registry data:
$ mkdir registry-data
Start your registry: Start your registry:
$ docker run -d -p 5000:5000 \ $ docker run -d -p 5000:5000 \
-v `pwd`/registry-data:/tmp/registry-dev \
--restart=always --name registry registry:2 --restart=always --name registry registry:2
That's it. That's it.
@ -31,6 +26,20 @@ Then pull it back:
$ docker pull localhost:5000/batman/ubuntu $ docker pull localhost:5000/batman/ubuntu
## Where is my data?
By default, your registry stores its data on the local filesystem, inside the container.
In a production environment, it's highly recommended to use [another storage backend](https://github.com/docker/distribution/blob/master/docs/storagedrivers.md), by [configuring it](https://github.com/docker/distribution/blob/master/docs/configuration.md#storage).
If you want to stick with the local posix filesystem, you should store your data outside of the container.
This is achieved by mounting a volume into the container:
$ docker run -d -p 5000:5000 \
-e REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/var/lib/registry \
-v /myregistrydata:/var/lib/registry \
--restart=always --name registry registry:2
## Making your Registry available ## Making your Registry available
@ -41,7 +50,12 @@ Let assume your registry is accessible via the domain name `myregistrydomain.com
If you try to `docker pull myregistrydomain.com:5000/batman/ubuntu`, you will see the following error message: If you try to `docker pull myregistrydomain.com:5000/batman/ubuntu`, you will see the following error message:
``` ```
FATA[0000] Error response from daemon: v1 ping attempt failed with error: Get https://myregistrydomain.com:5000/v1/_ping: tls: oversized record received with length 20527. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry myregistrydomain.com:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt FATA[0000] Error response from daemon: v1 ping attempt failed with error:
Get https://myregistrydomain.com:5000/v1/_ping: tls: oversized record received with length 20527.
If this private registry supports only HTTP or HTTPS with an unknown CA certificate,please add
`--insecure-registry myregistrydomain.com:5000` to the daemon's arguments.
In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag;
simply place the CA certificate at /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt
``` ```
If trying to reach a non `localhost` registry, Docker requires that you secure it using https, or make it explicit that you want to run an insecure registry. If trying to reach a non `localhost` registry, Docker requires that you secure it using https, or make it explicit that you want to run an insecure registry.
@ -62,7 +76,6 @@ docker stop registry && docker rm registry
# Start your registry with TLS enabled # Start your registry with TLS enabled
docker run -d -p 5000:5000 \ docker run -d -p 5000:5000 \
-v `pwd`/registry-data:/tmp/registry-dev \
-v `pwd`/certs:/certs \ -v `pwd`/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
@ -134,9 +147,9 @@ registry:
environment: environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt
REGISTRY_HTTP_TLS_KEY: /certs/domain.key REGISTRY_HTTP_TLS_KEY: /certs/domain.key
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /var/lib/registry
volumes: volumes:
- /path/registry-data:/data - /path/registry-data:/var/lib/registry
- /path/certs:/certs - /path/certs:/certs
``` ```

@ -10,4 +10,4 @@ An implementation of the `storagedriver.StorageDriver` interface which uses the
## Parameters ## Parameters
`rootdirectory`: (optional) The root directory tree in which all registry files will be stored. Defaults to `/tmp/registry/storage`. `rootdirectory`: (optional) The root directory tree in which all registry files will be stored. Defaults to `/var/lib/registry`.

@ -16,7 +16,7 @@ import (
) )
const driverName = "filesystem" const driverName = "filesystem"
const defaultRootDirectory = "/tmp/registry/storage" const defaultRootDirectory = "/var/lib/registry"
func init() { func init() {
factory.Register(driverName, &filesystemDriverFactory{}) factory.Register(driverName, &filesystemDriverFactory{})