nix2container icon indicating copy to clipboard operation
nix2container copied to clipboard

Request: easy way to get resulting image name

Open tennox opened this issue 1 year ago • 2 comments

After

nix run .#dockerImage.copyToDockerDaemon

I want to run the image - I found this hacky way:

docker run (nix eval --impure --expr '(builtins.getFlake (toString ./.)).outputs.packages.x86_64-linux.dockerImage.imageRefUnsafe' --json | jq -r)

Could there be a simpler way? (or is there already?)

e.g. nix run .#dockerImage.printImageRef :tipping_hand_man:

tennox avatar Jan 20 '24 12:01 tennox

I adapted my taskfile to just print the image ref to ./result - so I can

docker run $(cat result)

But I guess that doesn't quite fit a nix run cli :thinking: (and nix2container isn't really meant for nix build, is it?)

tennox avatar Jan 20 '24 12:01 tennox

Found that I can set:

nix2container.buildImage {
  tag = "latest";

and then docker run image:latest

is this good practice? Not sure what other gotchas this might have :thinking:

tennox avatar Jan 21 '24 17:01 tennox