How to update a declarative docker container?

I deployed a docker container on NixOS:

  docker-containers = {
    statping = {
      image = "statping/statping";
      ports = [ "" ];
      volumes = [ "/var/lib/statping:/app" ];

It has the version 0.90.61. Now version 0.90.63 is available.

How to update it best?

I tried image = "statping/statping:latest"; and nixos-rebuild switch, but it had no effect.

You can add arguments to container startups using, based on this issue on GitHub, I guess you could add --pull=[always,*missing,never] argument.

I believe the downside would be that the reproducibility is broken, yet, that is already the case with the forced image cache.

1 Like

Assuming that the versions are also published as docker registry tags: image = "statping/statping:0.90.63";.

Or to be even more precise (as registry tags are not immutable):

$ docker pull statping/statping
Using default tag: latest
latest: Pulling from statping/statping
df20fa9351a1: Pull complete 
5c204dc2c2ee: Pull complete 
eb9bfc882807: Pull complete 
8393a82503e5: Pull complete 
0496e962de56: Pull complete 
638b01723b94: Pull complete 
Digest: sha256:07baab386665f787c8672ad99b448914fd0fc46f6e5010f2cfac101c89f1fa9f
Status: Downloaded newer image for statping/statping:latest

Copy the value on the Digest: line like this:

  image = "statping/statping@sha256:07baab386665f787c8672ad99b448914fd0fc46f6e5010f2cfac101c89f1fa9f";`.

Not only updated, but also reproducible. Perfect.

You can find the Digest also here: Docker Hub

Thank you!