Automatically upload docker image to GitHub docker registry


Original text transferred from:Upload docker image to GitHub docker registry automatically with drone

Automatically upload docker image to GitHub docker registry

I’m glad to receive itGitHubGet started with your beta invitationGitHub Package RegistryRelated functions. You can know from the description file that registry currently supports several packages, such asnpm, gem, docker, mvnandnuget, this article mainly introduces how to use drone to quickly connect the “automatically upload docker image to GitHub Registry” of CI / CD process. At the end, let’s see how to use the docker registry provided by GitHub.

Teaching film…

For more practical videos, please refer to my udemy teaching series

GitHub certification

$ docker login \

The quickest way to log in to GitHub’s docker registry is to log in directly with your personal account and password, and the registry setting isdocker.pkg.github.comHere, please note that although the official has written that you can log in with your personal password, if you log in with OTP, this method is not applicable and safe. Personally, I strongly recommend that you establish an exclusive token in the background.

Automatically upload docker image to GitHub docker registry

amongread:packages and write:packagesPlease check the two scopes. If it is a private repo, thenrepoCheck the option, so you can get a token as a password. You candocker loginLet’s log in and try

Tandem drone CI / CD

From commit to automatic uploading of docker image can be quickly completed through drone. Let’s create it firstDockerfile

FROM plugins/base:multiarch

LABEL maintainer="Bo-Yi Wu <[email protected]>" \"Drone Workshop" \
  org.label-schema.vendor="Bo-Yi Wu" \

ADD release/linux/amd64/helloworld /bin/

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD [ "/bin/helloworld", "-ping" ]

ENTRYPOINT ["/bin/helloworld"]

Then through the official dronedockerSuite to complete automated upload

kind: pipeline
name: default

- name: build
  image: golang:1.13
  - make build_linux_amd64

- name: docker
  image: plugins/docker
    auto_tag: true
    auto_tag_suffix: linux-amd64
    username: appleboy
      from_secret: docker_password

The difference between GitHub and dockerhub is that the format of GitHub isOWNER/REPOSITORY/IMAGE_NAME, notice there’s one more in the middleREPOSITORYDockerhub isOWNER/IMAGE_NAME。 Then go backstage anddocker_passwordAfter setting, you can deploy correctly.

This work adoptsCC agreement, reprint must indicate the author and the link to this article