Working with Docker

 

Bintray can act as a fully-fledged repository for your Docker images, and works seamlessly with the Docker client. All you need to do is point your Docker client at Bintray, and you can issue Docker commands as usual in order to do the following:

  • Push – push an image to Docker repository in Bintray

  • Pull – pull an image from a Docker repository in Bintray

  • Search – search for images within a Docker repository in Bintray

  • Delete – delete images from a Docker repository in Bintray

Once your Docker images are stored on Bintray, you can use the Bintray UI to browse through them.

Terminology
Some of the terminology used in Docker and Bintray overlaps, but does not mean quite the same thing. To understand this page, please note that:

  • A Docker “tag” translates to a Bintray “version”

  • A Docker “namespace:repository” translates to a Bintray “package”

Configuring Docker
In order for Docker to work with Bintray, you need to set your credentials by adding an entry into your ~/.dockercfg file for each Bintray repository you want Docker to access. (Note that you may have to manually create the ~/dockercfg file in your home directory).

Each entry contains the following fields:

  • auth: Your authenticated username which is your Bintray username and Bintray API Key formattedusername:apikey, and then Base64 encoded.

  • email: Your email address.

 { 	"https://<Bintray_username>-docker-<Bintray_repo_name>.bintray.io" : { 	"auth" : "<Authenticated Base64 encoded username:apikey>", 	"email" : "<Your email*>"     } }

There’s no need to type out your ~/.dockercfg entries manually. You can ask Bintray to deliver them to you by executing the following cURL command:

curl -X GET -u<Bintray_username>:<API_KEY> https://<Bintray_username>-docker-Bintray_repo_name.bintray.io/v1/auth

For example, if you are registered in Bintray as “jayfrog”, and you want to access a Bintray repository called “whalesnthings” from your Docker client, you would execute the following cURL command to get your .dockercfg entry:

curl -X GET -ujayfrog:d81a391eea1af548af3fbf30b9d6979c4afdfd1f https://jayfrog-docker-whalesnthings.bintray.io/v1/auth

It’s easy to get this cURL command directly from Bintray. Just click SET ME UP! on the corresponding Bintray repository page.

Setting up Docker

Executing Docker Commands on Bintray
You can use Bintray as a Docker registry for push, pull, search and delete operations. The registry URL includes your user (or organization) name, and should have the following format:

{subject}-docker-{repo}.bintray.io/[{namespace}/]{docker_repo}[:{tag}]

where:

  • {subject}: The user or organization name

  • {repo}: The Bintray repository name

  • {namespace}/{docker_repo}: {namespace} is the Docker namespace you have applied. This is used as the prefix for the Bintray package name (Default: library).

    {namespace}:{docker_repo} is your Bintray package.

  • {tag}: The Docker tag (Default: latest)

Push and pull
The format for a Docker push or pull command is:

docker push/pull {subject}-docker-{repo}.bintray.io/[{namespace}/]{docker_repo}[:{version}]

For example,

docker push jayfrog-docker-whalesnthings.bintray.io/insects/flies

Note that to push to a repository, you must have configured Docker with your Bintray credentials as described above. This ensures that only the repository owner can push to it.

When pulling from a Bintray repository, you only have to configure Docker with your Bintray credentials if you are pulling from a private repository. Pulling from a public repository can be done anonymously and therefore does not require a corresponding ~/.dockercfg entry.

Search
The format for a Docker search command is:

docker search {subject}-docker-{repo}.bintray.io/{search-string}

For example,

docker search jayfrog-docker-whalesnthings.bintray.io/flies

Note: Since the Docker client does not send authentication credentials on a search, you can only search through public repositories, since those allow for anonymous access.

Delete
Deletion of Docker tags and repositories automatically cleans up any orphan layers that are left (layers not used by any other tag/repository). Currently, the Docker client does not support DELETE commands, but deletion can be triggered manually using cURL.

For more details, please refer to Delete Docker Repository and Delete Docker Tag in the Bintray REST API Documentation.