nlewo / nix2container

An archive-less dockerTools.buildImage implementation
Apache License 2.0
501 stars 45 forks source link

Request: easy way to get resulting image name #111

Open tennox opened 7 months ago

tennox commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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: