Home > Software engineering >  Docker: how to handle "latest" in a CI context with automatic updates but without redundan
Docker: how to handle "latest" in a CI context with automatic updates but without redundan

Time:11-14

What I want to achieve is that I give a colleague a docker container to run locally (via docker run) on his PC. I build this often via Gitlab CI and push it with a version tag (Semver 2.0) to Nexus.

Colleague should get a simple bash script like so:

#!/bin/bash
docker run -it -p 8080:80 nexus.company.net/goodservice:latest --dependency-overrides=local
echo "find the good service under http://localhost:8080, have fun!"

("--dependency-overrides" is a simple method I just implemented so that he can run the whole thing without Redis, I replace the implementations in the DI container this way.)

Problem:

Once a version (say: 1.0.1-pre.5) is downloaded, "latest" doesn't do any updates anymore.

I could EASILY fix it by using "--pull=always" on docker run but it's a .NET image of overall size about 100 MB (it's alpine already, but it still is a lot). Colleague is on a metered 4G Internet connection.

Is there any method to make docker check if "latest" is something else now? Didn't find anything in the documentation.

(If somebody from docker (or CNCF?) reads this: would be great to have an option like "--pull=updated". :-))

Any ideas?

CodePudding user response:

Add a docker pull command to your script. It'll only pull the image if it has been updated.

#!/bin/bash
docker pull nexus.company.net/goodservice:latest
docker run -it -p 8080:80 nexus.company.net/goodservice:latest --dependency-overrides=local
echo "find the good service under http://localhost:8080, have fun!"

If you want to limit the amount of data needed to be downloaded, you want to make sure that you typically only touch the last layer of the image when you create a new version. That way your colleague only needs to download the last layer and not the entire image.

  • Related