How to integrate Docker Distribution (private registry) with Atlassian Bitbucket Server?

To deploy a project I need some official containers (e.g. like alpine) and some non-disclosed (private) containers I cannot push to even a private Docker hub repository.

I found the Docker Distribution package which include Dockers “new registry”.

I also have a running installation von Atlassian Bitbucket Server which is a Git server solution. I would like to use Bitbucket as the master Git server for the non-disclosed Docker containers. So that I can create new Git repositories and set permissions inside Bitbucket and Docker Distribution will use that single Bitbucket project (with N projects inside) as the “registry”.

I was thinking of a setup which would like do the following:

Private container

  1. Searching for Docker container “foobar”.
  2. Docker will search the private “registry” for “foobar” and finds it.
  3. Docker installs “foobar” from the private “registry”

Public container

  1. Searching for Docker container “foobaz”.
  2. Docker will search the private “registry” for “foobaz” and does NOT find it.
  3. Docker will search the public “registry” (hub.docker.com) for “foobaz” and finds it.
  4. Docker installs “foobar” from the public “registry”

How to integrate Docker Distribution (private registry) with Atlassian Bitbucket Server?