pdtpartners / nix-snapshotter

Brings native understanding of Nix packages to containerd
MIT License
532 stars 15 forks source link

Using with Arion or docker-compose #135

Closed mjmeintjes closed 2 months ago

mjmeintjes commented 5 months ago

I'm trying to figure out how to use nix-snapshotter to run images that are then composed using Arion , nix frontend for docker-compose.

I've set it up like this:

  services.redis = { pkgs, lib, ... }: {
    service.image = "nix:0${pkgs.nix-snapshotter.buildImage {
        name = "ghcr.io/pdtpartners/redis";
        tag = "latest";
        config.entrypoint = [ "${pkgs.redis}/bin/redis-server" ];
    }}";
  };

But when I run it, I get the following error:

❯ arion up
/nix/store/hfs26lgg6qi2cki1kz6s2vwk3x0bjm0z-docker-compose.yaml
Pulling test (nix:0/nix/store/0cdzy9y0bh1qh95blp9rgm5pgwivyhhx-nix-image-redis.tar:)...
ERROR: Get "https://nix:0/v2/": dial tcp: lookup nix: no such host

Does anyone have any experience using nix-snapshotter with Arion or docker-compose?

steveej commented 3 months ago

you could try loading the image first.

in this specific case:

sudo nix2container /nix/store/0cdzy9y0bh1qh95blp9rgm5pgwivyhhx-nix-image-redis.tar

you'd probably want a way that hooks into arion up and does this for you.

steveej commented 2 months ago

@mjmeintjes did you configure Arion to use containerd? looking more into it i got the understanding that it uses docker by default which isn't using the configured snapshotter? would be great if you could share a full config to demonstrate how you could this working.

mjmeintjes commented 2 months ago

@mjmeintjes did you configure Arion to use containerd? looking more into it i got the understanding that it uses docker by default which isn't using the configured snapshotter? would be great if you could share a full config to demonstrate how you could this working.

I could not get nix-snapshotter working with Arion, and we've since migrated most of our docker containers to nixos and nixos-containers so I haven't spent any more time on this.