# Technical Documentation: NilsIrl/dockerc

> ℹ️ **Provenance:** In-Tree Documentation (4 Chapters) · [CodeWiki Reference](https://codewiki.google/github.com/NilsIrl/dockerc) · Recency: Active (< 180 days)

## File: README.md

# dockerc - compile docker images to standalone portable binaries

No more [][4]

No more `docker run`, no more `pip install`, no more `npm i`, just give your users executables they can run!


## Usage

Install dockerc from the [latest release](https://github.com/NilsIrl/dockerc/releases).


```
# Image from docker hub
$ dockerc --image docker://oven/bun --output bun
# Image in local docker daemon storage
$ dockerc --image docker-daemon:mysherlock-image:latest --output sherlock_bin
# Specify target instruction set architecture
$ dockerc --image docker://hello-world --arch arm64 --output hello
```

The output binary can then be called as you would with usual binaries. You can
also specify `-e`, and `-v` in the same way you would when using `docker run`.
Networked services running inside the container can be accessed directly without
having to specify `-p`.

Skopeo is used for loading images, for other locations refer to [its documentation][1].

## Build from source

Please note that this project uses Git submodules. If you clone this repository, you may need to run the following commands to initialize and update the submodules:

```
$ git submodule init
$ git submodule update
```

This will ensure that you download and update all relevant submodule contents.

dockerc uses a patched version of the zig compiler than can be found on the
[nils-dockerc-version branch][5] of the NilsIrl/zig repository. There is an
[open PR][6] for the patch to be included in upstream zig.

To compile dockerc use the following commands:

```
$ zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-musl
$ zig build -Doptimize=ReleaseSafe -Dtarget=aarch64-linux-musl
```

## Features

- [X] Compile docker images into portable binaries
- [X] Rootless containers
- [ ] MacOS and Windows support (using QEMU)
- [X] x86_64 support
- [X] arm64 support
- [X] Supports arguments
- [X] [Supports specifying environment variables using `-e`][2]
- [X] [Supports specifying volumes using `-v`][3]
- [ ] Support other [arguments][0]...

[0]: https://docs.docker.com/engine/reference/commandline/container_run/
[1]: https://github.com/containers/skopeo/blob/main/docs/skopeo.1.md#image-names
[2]: https://docs.docker.com/reference/cli/docker/container/run/#env
[3]: https://docs.docker.com/reference/cli/docker/container/run/#volume
[4]: https://www.reddit.com/r/github/comments/1at9br4/i_am_new_to_github_and_i_have_lots_to_say/
[5]: https://github.com/NilsIrl/zig/tree/nils-dockerc-version
[6]: https://github.com/ziglang/zig/pull/21092

---

## File: BUILD.md

```
sudo apt install libzstd-dev
./configure --without-xz --without-zlib LDFLAGS="-static"
make LDFLAGS="-all-static" -j
```

```
zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-musl
```

Examples images to try on:

* https://github.com/oven-sh/bun?tab=readme-ov-file#install
* https://github.com/containers/skopeo/blob/main/install.md#container-images
* https://github.com/shepherdjerred/macos-cross-compiler

---

## File: src/tools/policy.json

{
    "default": [
        {
            "type": "insecureAcceptAnything"
        }
    ]
}

---

## File: .github/workflows/ci.yml

on: [push]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: goto-bus-stop/setup-zig@v2
        with:
          version: 0.13.0
      - run: zig fmt --check .
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'recursive'
      - uses: actions/setup-go@v5
        with:
          go-version: '1.22.6'
      - uses: goto-bus-stop/setup-zig@v2
        with:
          version: 0.13.0
      - run: sudo apt install autoconf libtool pkg-config make libzstd-dev libfuse3-dev
      - run: zig build -Doptimize=ReleaseSafe -Dtarget=x86_64-linux-musl
      - run: zig-out/bin/dockerc --image docker://hello-world --output enlo
      - run: ./enlo

--- METRICS ---
- Files Extracted: 4
- Estimated Token Budget: ~1064 tokens
- Recency Window: Active (< 180 days)
- Canonical Reference: https://codewiki.google/github.com/NilsIrl/dockerc
