如何自动更新Docker Hub的完整说明? [英] How can I update full description on Docker Hub automatically?

查看:1226
本文介绍了如何自动更新Docker Hub的完整说明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Travis CI从Dockerfiles建立码头图像,然后将其推送到Docker Hub。



我创建了一个MD文件,描述图像和如何使用它。我想在Docker Hub的完整说明部分中有相同的描述。



由于我将来可能会更新说明,我希望Travis CI会根据存储库中的MD文件,使用新的映像自动更新描述。 p>

任何人都知道该怎么做?

解决方案

由于


然后向下滚动构建设置页面到构建触发器部分并复制触发器URL:



现在编辑您的 .travis.yml 文件,并添加以下块<您的帐户> <您的图片> 占位符):

  after_success:
#通知Docker Hub创建一个新的build
- >
[$ TRAVIS_BRANCH==master]
&&& curl -X POST -HContent-Type:application / json
--data'{docker_tag_name:latest}'
https://registry.hub.docker.com/u /< your account> /< your image> / trigger / $ DOCKER_HUB_TOKEN /

然后转到您的Travis CI网站上的项目页面,并打开项目设置:



并将 DOCKER_HUB_TOKEN 环境变量添加到Travis CI项目中,并使用触发令牌在Docker Hub Build设置页面上找到的值:



您仍然需要Github或B与您的Docker Hub项目相关联的itbucket存储库,但Travis CI将是指导Docker Hub何时构建您的映像。


I'm using Travis CI for building docker images from Dockerfiles and then pushing them to the Docker Hub on success.

I've created an MD file describing the image and how to use it. I want to have the same description on the Docker Hub in the full description section.

As I may update the description in the future, I want to have Travis CI automatically update the description based on the MD file in the repository with the new image.

Anyone knows how to do this?

解决方案

Since the Docker Hub does not expose any API, the only way to send stuff to the Docker Hub remotely is with the docker push command, and this limits use to sending images.

On the other hand, if you let the Docker Hub service build your image for you from a Github or Bitbucket repository, then Docker Hub will update the long description by taking the content of the README.md file found on that repository. See the Understand the build process section from the Docker Hub's Automated Build documentation.

This implies that you host your Dockerfile and README.md files on Github or Bitbucket.


If you really need to first build your image on TravisCI (maybe because you also run automated tests on the built image), then you can have TravisCI trigger a webhook on Docker Hub to tell Docker Hub to build the image once TravisCI determined it was passing the tests.

To do so, in Docker Hub, configure your image as you would for automated build (hence associate a Github or Bitbucket project), but deactivate the automated feature:

Then scroll down on the Build settings page to the Build Trigger section and copy the trigger URL:

Now edit your .travis.yml file and add the following block (mind the <your account> and <your image> placeholders):

after_success:
# notify Docker Hub to make a new build
- >
  [ "$TRAVIS_BRANCH" == "master" ]
  && curl -X POST -H "Content-Type: application/json"
  --data '{"docker_tag_name": "latest"}'
  https://registry.hub.docker.com/u/<your account>/<your image>/trigger/$DOCKER_HUB_TOKEN/

Then go to your project page on the Travis CI website, and open the project settings:

And add the DOCKER_HUB_TOKEN environment variable to your Travis CI project with the trigger token value found on the Docker Hub Build Settings page:

You will still need a Github or Bitbucket repository associated to your Docker Hub project, but Travis CI will be the one to instruct Docker Hub when to build your image.

这篇关于如何自动更新Docker Hub的完整说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆