Automatically pull docker image container

I have a linux bare-metal server with docker installed.

I work on an core project on my computer.

My source code is pushed on github.

Each time i commit and push something, github triggers a webhook on my docker hub account.

Docker hub builds me a new image which contains my core application binaries. (docker hub also run the tests)

This image works fine when i pull it manually on my server.

My question is how can i do this automatically ? Is there a way for my server to "detect" that docker hub contains a new version of the image and run something to pull this image and fire database migrations automatically ?


1 answer

  • answered 2019-07-19 03:29 atline

    • If you have a public ip which external internet such as dockerhub could visit you, then you can use Docker Hub Webhooks:

      You can create webhooks like next diagram, set the url which external could visit your service, when image was pushed, it will post some json data to the url you afforded, one example data here, then your own url could receive data and do related things as you like.

      enter image description here

      And, if you use jenkins, there are lots of plugin help you to do similar things: refer Triggering Docker pipelines with Jenkins, also Polling Docker Registries for Image Changes

    • If you not have a public ip which dockerhub could visit, then I guess you had to poll dockerhub to see if new image there...