37

I am trying to push a docker image to my private repo on docker hub. However, I do see that there is an "Information" section on the Docker Hub which I want to update with useful information about my image. I am wondering if I can push a README.md file and Docker Hub can parse this file and update the "Information" section with this. I am not sure if I should embed the README.md in my image for this to work?

sunsin1985
  • 2,437
  • 5
  • 22
  • 27
  • Instead of updating manually you can automate it with a call to the Docker Hub API. See my answer below for a utility I created to do this. https://stackoverflow.com/questions/29134275/how-to-push-a-docker-image-with-readme-file-to-docker-hub/57671247#57671247 – peterevans Sep 27 '19 at 03:03

3 Answers3

28

Docker Hub will try to parse your Readme.md if you're doing an "Automated Build." For manual builds (where you push your own image), Docker Hub does not peek inside your image source code repository and has no way to know about your Readme. You'll need to manually add your Readme text to the Information section

ehsan shirzadi
  • 4,709
  • 16
  • 69
  • 112
Andy
  • 35,844
  • 6
  • 43
  • 50
  • Thanks @Andy, I also arrived at the same conclusion and updated the Information manually on Docker Hub. – sunsin1985 Mar 19 '15 at 00:38
  • 5
    FYI: [Automated builds are no longer available for unpaid Docker Hub accounts](https://www.docker.com/blog/changes-to-docker-hub-autobuilds/) – smheidrich Jan 23 '22 at 21:34
22

dockerhub-description GitHub Action can update the Docker Hub description from a README.md file.

    - name: Docker Hub Description
      uses: peter-evans/dockerhub-description@v3
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        repository: peterevans/dockerhub-description

You can also use it independently of GitHub Actions in other CI tools.

    docker run -v $PWD:/workspace \
      -e DOCKERHUB_USERNAME='user1' \
      -e DOCKERHUB_PASSWORD='xxxxx' \
      -e DOCKERHUB_REPOSITORY='my-docker-image' \
      -e README_FILEPATH='/workspace/README.md' \
      peterevans/dockerhub-description:2.1.0
Willemoes
  • 5,752
  • 3
  • 30
  • 27
peterevans
  • 34,297
  • 7
  • 84
  • 83
  • 1
    Is that considered safe to expose your docker account password to a 3rd party container? Is somewhere an audit showing that it doesn't expose your credentials? – Anton Krug May 05 '21 at 20:11
  • 1
    @AntonKrug As with all third-party actions, it's good practice to fork the action, check the code, and use your fork in workflows. The action is open source so you can check how it works. – peterevans May 06 '21 at 01:21
  • I'm not saying yours is, but overall blindly depending on various containers without checking is not good, just because it's open-sourced doesn't guarantee its safety. Yes using specific validated tag is not bad. I think it happened to many web-browser addons that were OSS project changed owners and with the new updated version came malware. – Anton Krug May 06 '21 at 01:36
  • @AntonKrug The action itself doesn't use a container. So if you fork the code and use your fork there is no way for malware to be introduced. There is a Docker version of the action that can be run outside of GitHub Actions. That does require trust in the owner if you use the published container. You could, of course, build and publish your own copy. – peterevans May 06 '21 at 02:33
  • Works. FYI needs Delete Permission on Token for Docker Hub. – Peter Kofler Aug 30 '23 at 16:39
18

docker-pushrm is a Docker CLI plugin that adds a new docker pushrm (speak: push readme) command to Docker. When it's installed you can push a README to Docker Hub, Quay or Harbor with:

$ ls
README.md
$ docker pushrm my-user/my-repo

It uses the the logins from Docker's credentials store, so it "just works" for registries that you're already logged into. I use it both interactively and for CI. There's also a github action based on it.

Chris
  • 567
  • 6
  • 24