The toolkit to pack, ship, store, and deliver container content
Find a file
Josh Hawn 731e0b0066 Improve context package
You shouldn't have to import both:

  github.com/docker/distribution/context
  golang.org/x/net/context

just to use the distribution tools and implement the distribution interfaces.

By pulling the Context interface from golang.org/x/net/context into the
context package within the distribution project, you no longer have to import
both packages.

Note: You do not have to change anything anywhere else yet! All current uses
of both packages together will still work correctly because the Context
interface from either package is identical.

I've also made some other minor changes:

- Added a RemoteIP function. It's like RemoteAddr but discards the port suffix
- Added `.String()` to the response duration context value so that JSON log
  formatting shows human-parseable duration and not just number of nano-seconds
- Added WithMapContext(...) to the context package. This is a useful function
  so I pulled it out of the main.go in cmd/registry so that it can be used
  elsewhere.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
2015-04-01 15:40:21 -07:00
cmd Improve context package 2015-04-01 15:40:21 -07:00
configuration Improve context package 2015-04-01 15:40:21 -07:00
context Improve context package 2015-04-01 15:40:21 -07:00
digest Remove unnecessary error pointer formats in test 2015-03-18 19:02:32 -07:00
doc Merge pull request #283 from sthulb/client-certs 2015-03-31 16:45:03 -07:00
Godeps Update logrus dependency in Godep 2015-03-24 16:56:43 -07:00
health Adding first version of HealthCheck 2015-03-20 14:38:40 -07:00
manifest Specify manifest schema version 1 media type 2015-02-19 16:47:13 -08:00
notifications Verify IP addresses 2015-03-25 11:11:46 -07:00
project Adds pre-commit hook, hook config script, and a README 2014-12-15 18:09:11 -08:00
registry Merge pull request #294 from fkautz/pr_out_updating_msopentech_azure_sdk_for_go_to_latest_master 2015-03-24 13:27:19 -07:00
testutil Move testutil package to top-level 2015-01-05 16:53:13 -08:00
version Update AUTHORS and default version package 2015-03-02 23:39:19 -08:00
.drone.yml Fix goverall 2014-11-22 10:17:14 -08:00
.gitignore Improve context package 2015-04-01 15:40:21 -07:00
.mailmap Update mailmap file with some new aliases 2015-02-16 14:21:28 -08:00
AUTHORS Verify IP addresses 2015-03-25 11:11:46 -07:00
circle.yml Move to godep 2015-01-22 15:52:46 -08:00
CONTRIBUTING.md Update Sprint label link from Ready 2015-03-17 18:56:56 -07:00
doc.go Move registry package out of repo root 2015-01-06 10:40:22 -08:00
Dockerfile Update Dockerfile to use Makefile to build binary 2015-01-29 18:32:16 -08:00
errors.go Add error return to Repository method on Registry 2015-02-13 16:27:33 -08:00
LICENSE Initial commit 2014-12-22 15:49:26 -08:00
MAINTAINERS Add Stephen Day to maintainers file 2015-01-28 10:31:54 -08:00
Makefile Removing dependencies from Makefile AUTHORS target that break build in pristine git env 2015-02-23 15:11:04 -08:00
README.md Add ROADMAP.md to the project and cleanup existing items 2015-03-18 16:15:34 -07:00
registry.go Refactor Layer interface to return a Handler 2015-03-12 21:59:07 -07:00
ROADMAP.md more formatting... 2015-03-18 19:02:37 -07:00

Notice: This repository hosts experimental components that are currently under heavy and fast-paced development, not-ready for public consumption. If you are looking for the stable registry, please head over to docker/docker-registry instead.

Distribution

The Docker toolset to pack, ship, store, and deliver content.

The main product of this repository is the new registry implementation for storing and distributing docker images. It supersedes the docker/docker- registry project with a new API design, focused around security and performance.

The Distribution project has the further long term goal of providing a secure tool chain for distributing content. The specifications, APIs and tools should be as useful with docker as they are without.

This repository contains the following components:

  • registry (beta): An implementation of the Docker Registry HTTP API V2 for use with docker 1.5+.
  • libraries (unstable): A rich set of libraries for interacting with distribution components. Please see godoc for details. Note that the libraries are not considered stable.
  • dist (experimental): An experimental tool to provide distribution oriented functionality without the docker daemon.
  • specifications: Distribution related specifications are available in doc/spec.
  • documentation: Documentation is available in doc.

How will this integrate with Docker engine?

This project should provide an implementation to a V2 API for use in the Docker core project. The API should be embeddable and simplify the process of securely pulling and pushing content from docker daemons.

What are the long term goals of the Distribution project?

Design a professional grade and extensible content distribution system, that allow users to:

  • Enjoy an efficient, secured and reliable way to store, manage, package and exchange content
  • Hack/roll their own on top of healthy open-source components
  • Implement their own home made solution through good specs, and solid extensions mechanism.

Features

The new registry implementation provides the following benefits:

  • faster push and pull
  • new, more efficient implementation
  • simplified deployment
  • pluggable storage backend
  • webhook notifications

For information on upcoming functionality, please see ROADMAP.md.

Installation

TODO(stevvooe): Add the following here:

  • docker file
  • binary builds for non-docker environment (test installations, etc.)

Configuration

The registry server can be configured with a yaml file. The following is a simple example that can used for local development:

version: 0.1
loglevel: debug
storage:
    filesystem:
        rootdirectory: /tmp/registry-dev
http:
    addr: localhost:5000
    secret: asecretforlocaldevelopment
    debug:
        addr: localhost:5001

The above configures the registry instance to run on port 5000, binding to "localhost", with the debug server enabled. Registry data will be stored in "/tmp/registry-dev". Logging will be in "debug" mode, which is the most verbose.

A similar simple configuration is available at [cmd/registry/config.yml], which is generally useful for local development.

**TODO(stevvooe): Need a "best practice" configuration overview. Perhaps, we can point to a documentation section.

For full details about configuring a registry server, please see the documentation.

Upgrading

TODO: Add a section about upgrading from V1 registry along with link to migrating in documentation.

Build

If a go development environment is setup, one can use go get to install the registry command from the current latest:

go get github.com/docker/distribution/cmd/registry

The above will install the source repository into the GOPATH. The registry binary can then be run with the following:

$ $GOPATH/bin/registry -version
$GOPATH/bin/registry github.com/docker/distribution v2.0.0-alpha.1+unknown

The registry can be run with the default config using the following incantantation:

$ $GOPATH/bin/registry $GOPATH/src/github.com/docker/distribution/cmd/registry/config.yml
INFO[0000] endpoint local-8082 disabled, skipping        app.id=34bbec38-a91a-494a-9a3f-b72f9010081f version=v2.0.0-alpha.1+unknown
INFO[0000] endpoint local-8083 disabled, skipping        app.id=34bbec38-a91a-494a-9a3f-b72f9010081f version=v2.0.0-alpha.1+unknown
INFO[0000] listening on :5000                            app.id=34bbec38-a91a-494a-9a3f-b72f9010081f version=v2.0.0-alpha.1+unknown
INFO[0000] debug server listening localhost:5001

If it is working, one should see the above log messages.

Repeatable Builds

For the full development experience, one should cd into $GOPATH/src/github.com/docker/distribution. From there, the regular go commands, such as go test, should work per package (please see Developing if they don't work).

A Makefile has been provided as a convenience to support repeatable builds. Please install the following into GOPATH for it to work:

go get github.com/tools/godep github.com/golang/lint/golint

TODO(stevvooe): Add a make setup command to Makefile to run this. Have to think about how to interact with Godeps properly.

Once these commands are available in the GOPATH, run make to get a full build:

$ GOPATH=`godep path`:$GOPATH make
+ clean
+ fmt
+ vet
+ lint
+ build
github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar
github.com/Sirupsen/logrus
github.com/docker/libtrust
...
github.com/yvasiyarov/gorelic
github.com/docker/distribution/registry/handlers
github.com/docker/distribution/cmd/registry
+ test
...
ok    github.com/docker/distribution/digest 7.875s
ok    github.com/docker/distribution/manifest 0.028s
ok    github.com/docker/distribution/notifications  17.322s
?     github.com/docker/distribution/registry [no test files]
ok    github.com/docker/distribution/registry/api/v2  0.101s
?     github.com/docker/distribution/registry/auth  [no test files]
ok    github.com/docker/distribution/registry/auth/silly  0.011s
...
+ /Users/sday/go/src/github.com/docker/distribution/bin/registry
+ /Users/sday/go/src/github.com/docker/distribution/bin/registry-api-descriptor-template
+ /Users/sday/go/src/github.com/docker/distribution/bin/dist
+ binaries

The above provides a repeatable build using the contents of the vendored Godeps directory. This includes formatting, vetting, linting, building, testing and generating tagged binaries. We can verify this worked by running the registry binary generated in the "./bin" directory:

$ ./bin/registry -version
./bin/registry github.com/docker/distribution v2.0.0-alpha.2-80-g16d8b2c.m

Developing

The above approaches are helpful for small experimentation. If more complex tasks are at hand, it is recommended to employ the full power of godep.

The Makefile is designed to have its GOPATH defined externally. This allows one to experiment with various development environment setups. This is primarily useful when testing upstream bugfixes, by modifying local code. This can be demonstrated using godep to migrate the GOPATH to use the specified dependencies. The GOPATH can be migrated to the current package versions declared in Godeps with the following command:

godep restore

WARNING: This command will checkout versions of the code specified in Godeps/Godeps.json, modifying the contents of GOPATH. If this is undesired, it is recommended to create a workspace devoted to work on the Distribution project.

With a successful run of the above command, one can now use make without specifying the GOPATH:

$ make

If that is successful, standard go commands, such as go test should work, per package, without issue.

Support

If any issues are encountered while using the Distribution project, several avenues are available for support:

IRC: #docker-distribution on FreeNode Issue Tracker: github.com/docker/distribution/issues Google Groups: https://groups.google.com/a/dockerproject.org/forum/#!forum/distribution Mailing List: docker@dockerproject.org

Contribute

Please see CONTRIBUTING.md.

License

This project is distributed under Apache License, Version 2.0.