# Build Dockerfile/Containerfile with Nix

**URL:** https://discourse.nixos.org/t/build-dockerfile-containerfile-with-nix/62592
**Category:** Guides
**Created:** [April 3, 2025, 9:11am UTC](https://discourse.nixos.org/t/build-dockerfile-containerfile-with-nix/62592 "2025-04-03T09:11:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![imincik](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/i/6de8d8/32.png) [@imincik](https://discourse.nixos.org/u/imincik)
#### Post date: [April 3, 2025, 9:11am UTC](https://discourse.nixos.org/t/build-dockerfile-containerfile-with-nix/62592/1 "2025-04-03T09:11:17Z")

</div>

In case you have to deal with containers which can’t be easily rewritten to Nix,  
I wrote an interesting [Nix function](https://github.com/imincik/containerfile-nix/blob/9d1a4899360df5d8b96137bc7e0a1a8f42498588/build-containerfile.nix) which is capable of building a Dockerfile without any modification.

Check out [containerfile-nix](https://github.com/imincik/containerfile-nix/).

---

<div class="post-metadata">

### Author: ![mmlb](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mmlb/32/1303_2.png) [@mmlb](https://discourse.nixos.org/u/mmlb)
#### Post date: [April 10, 2025, 7:14pm UTC](https://discourse.nixos.org/t/build-dockerfile-containerfile-with-nix/62592/2 "2025-04-10T19:14:55Z")

</div>

I haven’t tried this out yet but have needed something like this for years. Not badly enough to go out and write it, but would have facilitated more nixification of some projects if it was available. Glad to see this!
