Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull new docker images and restart docker containers after building docker images on gitlab?

There is an asp.net core api project, with sources in gitlab. Created gitlab ci/cd pipeline to build docker image and put the image into gitlab docker registry (thanks to https://medium.com/faun/building-a-docker-image-with-gitlab-ci-and-net-core-8f59681a86c4).

How to update docker containers on my production system after putting the image to gitlab docker registry?

*by update I mean:

docker-compose down && docker pull && docker-compose up 
like image 665
Ali Avatar asked Oct 23 '25 15:10

Ali


1 Answers

Best way to do this is to use Image puller, lot of open sources are available, or you can write your own on the Shell. There is one here. We use swarm, and we use this hook concept to be triggered from our CI-CD pipeline. Once our build stage is done, we http the hook url, and the docker pulls the updated image.
One disadvantage with this is you need a daemon to watch your hook task, that it doesnt crash or go down. So my suggestion is to run this hook task as a docker container with restart-policy as RestartAlways

like image 180
Srini M Avatar answered Oct 26 '25 06:10

Srini M