3 ms·
(I know almost nothing about Nix, so take this question loosely) Do you know if there's an easy way to generate a Docker container from a Nix script? That coul
by StavrosK 7y ago
(I know almost nothing about Nix, so take this question loosely)
Do you know if there's an easy way to generate a Docker container from a Nix script? That could be a very nice alternative to a Dockerfile.
- tazjin 7y agoYes, you can do that using for example `buildLayeredImage`: { pkgs ? import <nixpkgs> {} }: with pkgs; dockerTools.buildLayeredImage { name = "curl-bash"; contents = [ curl bashInteractive coreutils ]; } Putting that in a file and calling `nix-build` on that file will give you a tarball that Docker will happily load using `docker load`. Doing this has a lot of advantages over Dockerfiles, see this blog post for some of the others: https://grahamc.com/blog/nix-and-layered-docker-images https://grahamc.com/blog/nix-and-layered-docker-images
- StavrosK 7y agoFantastic, thanks!