Publishing a Docker image to Bintray

Publishing a Docker image to Bintray isn’t that hard — but you have to know how!

Normally I’m a Java guy. So normally you expect a article about Kotlin, gradle or Maven or something. But the fact that all big CI providers backend on Docker lead to the fact that I have to investigate a little bit time into learning Docker.

Let’s start by showing you how to publish a Docker image to Bintray.

First of all, beside of having a Bintray account of course, you have to create a Docker repository on Bintray. Just go to your overview page, click on “Add new Repository”, choose Docker as type, name it somehow (e.g dockerhub) and click create.

For a successful docker push you have to set up your credentials in a file located at ~/.dockercfg . According to the docs from Bintray you can receive that file via a simple curl command. Unfortunately it wasn’t working for me. I just got the message:

That’s the reason why I suggest you to create the file manually.
To file needs the following syntax:

I think the file explained everything what do you have to replace 🙃.

Obviously to publishing a Docker image you need a Docker image first. For testing purpose I’ve created a simple Dockerfile like this:

To create the image just run the following command. The <ImageName> can be replaced with any name you like (e.g. bintray-publish-test):

Before you can finally publish the image you have to tag it. Bintray needs a special tag name for it. It’s build in the following way:

To take the image you have to first find the image via docker images . This will give you a great overview about all the Docker images on your machine. Find the image you have just created and copy the IMAGE ID .

To tag these image run:

Note: This tag is also your “final” image name. If someone wants to use your image in their Dockerfile they have to use these tag as image name.

Now you are finally ready to publish your image. And — it is really simple. Just run

To verify that everything works correctly you can create a new test project.
For that I created a new Dockerfile with the following content:

The <DockerTag> is the full name of the tag we have created above 👆.

To make sure that Docker will download the image from Bintray and don’t use a local copy of it remove the images from your machine:

Now you can build and run your test Dockerfile :

Now you have — hopefully — the Hello World output we expected 🎉.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store