Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—ensuring that all references point to valid memory—without requiring the use of a garbage collector or reference counting present in other memory-safe languages. To simultaneously enforce memory safety and prevent concurrent data races, its "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust is popularized for systems programming but also has high-level features including some functional programming constructs.
wikipedia.org/wiki/Rust_(programming_language)
The most straightforward way to use this image is to use a Rust container as both the build and runtime environment. In your Containerfile, writing something along the lines of the following will compile and run your project:
FROM ghcr.io/appjail-makejails/rust
WORKDIR /myapp
COPY . .
# Depending on your project, you'll need many packages. FreeBSD-set-base-jail
# installs many dependencies, although it may take up more unnecessary space
# than if only the necessary packages were installed.
RUN pkg install FreeBSD-set-base-jail && \
cargo install --path .
CMD ["myapp"]Then, build and run the OCI image:
$ buildah build --network=host -t my-rust-app .
$ appjail oci run \
-o overwrite=force \
-o ephemeral \
-o alias \
-o ip4_inherit \
localhost/my-rust-app my-rust-appThis creates an image that has all of the rust tooling for the image, which is 2.32 GiB. If you just want the compiled application:
FROM ghcr.io/appjail-makejails/rust
WORKDIR /myapp
COPY . .
RUN pkg install FreeBSD-set-base-jail && cargo install --path .
FROM ghcr.io/appjail-makejails/base
COPY --from=builder /usr/local/cargo/bin/myapp /usr/local/bin/myapp
CMD ["myapp"]This method will create an image that is only 34.5 MiB in size.
There may be occasions where it is not appropriate to run your app inside a container. To compile, but not run your app inside the container instance, you can write something like:
$ appjail oci run \
-o overwrite=force \
-o ephemeral \
-o alias \
-o ip4_inherit \
-o fstab="$PWD /myapp" \
-o pkg=FreeBSD-set-base-jail \
-o template=/usr/local/share/examples/appjail/templates/freebsd-oci.conf \
-w /myapp \
ghcr.io/appjail-makejails/rust my-rust-app \
cargo build --releaseThis will add your current directory, as a volume, to the container, set the working directory to the volume, and run the command cargo build --release. This tells Cargo, Rust's build system, to compile the crate in myapp and output the executable to target/release/myapp.
This repository includes a small Makejail that ultimately uses the OCI image, in case you prefer to use appjail-makejail(5).
$ appjail makejail \
-j rust \
-f gh+AppJail-makejails/rust \
-o alias \
-o ip4_inherit \
-o ephemeral \
-o container="args:--pull"
...
$ appjail cmd jexec rust cargo version
cargo 1.96.0 (30a34c682 2026-05-25) (built from a source tarball)rust_from(default:ghcr.io/appjail-makejails/rust): Location of OCI image. See also OCI Configuration.rust_tag(default:latest): OCI image tag. See also OCI Configuration.
PGID(default:1000): Equivalent toPUIDbut for the Process Group ID.PUID(default:1000): Process User ID for the container's main process, allowing you to match the owner of files written to mounted host volumes to your host system's user. Writable volumes are changed based on this environment variable.
build:
variants:
- tag: 15.1
containerfile: Containerfile
aliases: ["latest"]
default: true
args:
FREEBSD_RELEASE: "15.1"
NO_PKGCLEAN: "1"
cache_dirs: ["pkgcache0:/var/cache/pkg"]
- tag: 15.1-nightly
containerfile: Containerfile
args:
FREEBSD_RELEASE: "15.1"
NIGHTLY: 'yes'
NO_PKGCLEAN: "1"
cache_dirs: ["pkgcache0:/var/cache/pkg"]- The ideas present in the Docker image of Rust are taken into account for users who are familiar with it.
