How to update the containers in Googles container optimized os?

1.1k views Asked by At

I want to use a buddy pipeline to push new images to DockerHub. When new images are pushed, the Google Container Optimized OS should pull the new ones. I'm using a Google Computer engine to host docker-compose on Google Container optimized os. How can I do this?

1

There are 1 answers

0
Vi Pau On BEST ANSWER

Assuming you are using the ':latest' tag in docker-compose, the latest version of the image will always be pulled when you run this:

docker-compose down && docker-compose build --pull && docker-compose up
(be warned that the upgrade may cause a very slight downtime while the container images are being pulled)

This can be combined with the webhook support of Docker Hub in order to run this command when a new image is pushed. See https://docs.docker.com/docker-hub/webhooks/
You would need some endpoint for receiving the POST call from the webhook and execute the command, for example this: https://github.com/adnanh/webhook

It can be configured as an HTTP endpoint to receive the webhook from Docker Hub when the new image is pushed, to run the command above. For security reasons I would advise to use an HTTPS endpoint, and an IP whitelist for the incoming webhook that only allows traffic from Amazon ELB IPs (as that's what DockerHub uses). Additional you may want to verify that the Callback URL is from https://registry.hub.docker.com/.
Unfortunately DockerHub does not yet support the use of a secret to validate the caller: https://github.com/docker/roadmap/issues/51