This guide is accurate as of 2026-02-17. The build process of Grafana Alloy might change in the
future. Consult the upstream Dockerfile when the build fails.
This guide will help you build a forked version of Grafana Alloy.
# NOTE: This dockerfile is based on https://github.com/grafana/alloy/blob/b1cb806a2d9cc53c778fe8c8ccd79d7517b95965/Dockerfile#L1FROM--platform=$BUILDPLATFORMgrafana/alloy-build-image:v0.1.27ASui-build
ARGBUILDPLATFORM
ARGFORK_REPO=<GIT_FORKED_REPO_HERE>
ARGFORK_BRANCH=<GIT_FORKED_BRANCH_HERE>
RUNgitclone${FORK_REPO}--branch${FORK_BRANCH}--single-branch
RUNmkdir-p/ui
# Copy the contents of the cloned UI directory into /ui so package.json# and other top-level files end up at /ui rather than /ui/uiRUNcp-r./alloy/internal/web/ui/./ui
WORKDIR/uiRUN--mount=type=cache,target=/ui/node_modules,sharing=locked\npminstall\&&npmrunbuild
FROM--platform=$BUILDPLATFORMgrafana/alloy-build-image:v0.1.27ASbuild
ARGBUILDPLATFORM
ARGFORK_REPO=<GIT_FORKED_REPO_HERE>
ARGFORK_BRANCH=<GIT_FORKED_BRANCH_HERE>
ARGRELEASE_BUILD=1WORKDIR/src/alloyRUNgitclone${FORK_REPO}--branch${FORK_BRANCH}--single-branch.
COPY--from=ui-build/ui/dist/src/alloy/internal/web/ui/dist
RUN--mount=type=cache,target=/root/.cache/go-build\--mount=type=cache,target=/go/pkg/mod\GO_TAGS="netgo builtinassets promtail_journal_enabled"\makealloy
FROMpublic.ecr.aws/ubuntu/ubuntu:nobleASalloy-base# Username and uid for alloy userARGUID="473"ARGUSERNAME="alloy"# Force non-interactive mode for tzdata package installARGDEBIAN_FRONTEND="noninteractive"LABELorg.opencontainers.image.source="https://github.com/grafana/alloy"RUNapt-getupdate\&&apt-getupgrade-y\&&apt-getinstall-qy--no-install-recommends\ca-certificates\libsystemd0\tzdata\&&apt-getclean\&&rm-rf/var/lib/apt/lists/*/tmp/*/var/tmp/*
COPY--from=build--chown=${UID}:${UID}/src/alloy/build/alloy/bin/alloy
# Create alloy user in container, but do not set it as default## NOTE: non-root support in Docker containers is an experimental,# undocumented feature; use at your own risk.RUNgroupadd--gid$UID$USERNAME\&&useradd-m-u$UID-g$UID$USERNAME\&&mkdir-p/var/lib/alloy/data\&&chown-R$USERNAME:$USERNAME/var/lib/alloy\&&chmod-R770/var/lib/alloy
ENTRYPOINT["/bin/alloy"]ENVALLOY_DEPLOY_MODE=docker
CMD["run","/etc/alloy/config.alloy","--storage.path=/var/lib/alloy/data"]
Replace the following place in the Dockerfile with the following:
The placeholders occur two times.
<GIT_FORKED_REPO_HERE> with the git URL of the forked repo
<GIT_FORKED_BRANCH_HERE> with the branch name of the forked repo