Skip to content
randomcontainersPublic

About

Auto-updating lnav (Logfile Navigator) images for amd64 and arm64

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

lnav

Container images with lnav, the Logfile Navigator. lnav detects the format of each log file it opens: syslog, web server access logs, the JSON logs of journald, Bunyan or pino, and formats you define. It merges the messages of all files by time and lets you search, filter and query them with SQL, in its terminal UI or from scripts. lnav is compiled from the release tarball on Ubuntu and Alpine, for linux/amd64 and linux/arm64, and the images are rebuilt when lnav publishes a release and when the base image changes.

This is an unofficial build, not affiliated with or endorsed by the lnav project. Report problems with the image in this repository and lnav bugs at tstack/lnav.

Quick start

Count the requests in an access log by HTTP status:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" ghcr.io/randomcontainers/lnav \
  -n -c ';SELECT sc_status, count(*) AS hits FROM access_log GROUP BY sc_status' -c ':write-csv-to -' access.log

-n runs lnav without its terminal UI. Each -c runs a command once the files are loaded: one that starts with ; is an SQL query, one that starts with : is an lnav command, and :write-csv-to - prints the result of the last query as CSV. When no command writes to standard output, -n prints what the terminal UI would show at the end: the result of the last query as a table, or the log messages that are left after filtering, merged by time. Print only the errors of every log file in a directory:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" ghcr.io/randomcontainers/lnav \
  -n -c ':set-min-log-level error' logs/

Browse the same logs in the terminal UI, which needs -it:

docker run --rm -it --user "$(id -u):$(id -g)" -v "$PWD:/work" ghcr.io/randomcontainers/lnav logs/

Press ? for help and q to quit.

The entrypoint runs lnav under tini in /work, so file names are relative to the directory you mount, and without arguments it prints lnav's help. lnav reads gzip and bzip2 files, and archives that libarchive can unpack, such as .tar.gz and .zip. With docker run -i and no file names, it reads the log from standard input. This lists the ten paths requested most often from an nginx container named web, which writes its access log to standard output:

docker logs web 2>/dev/null | docker run --rm -i ghcr.io/randomcontainers/lnav \
  -n -c ';SELECT cs_uri_stem, count(*) AS hits FROM access_log GROUP BY 1 ORDER BY 2 DESC LIMIT 10' -c ':write-csv-to -'

Each log format is a table, with a column for every field the format defines, and the all_logs table has the messages of every format. The lnav documentation covers the commands, the SQL tables and functions and log formats.

Your own formats

lnav keeps its configuration, the formats you install and its sessions in $HOME/.lnav. HOME is /cache in the image, so these files go to /cache/.lnav for any UID. Mount a volume on /cache to keep them between runs. lnav creates /cache/.lnav with mode 0750 for the UID that first uses the volume, and other UIDs cannot install formats there, so use the same --user every time with a given volume. -i installs a format definition:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" -v lnav-cache:/cache \
  ghcr.io/randomcontainers/lnav -i myapp_log.json
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" -v lnav-cache:/cache \
  ghcr.io/randomcontainers/lnav -n -c ';SELECT count(*) FROM myapp_log' -c ':write-csv-to -' app.log

Without a volume, -I <dir> adds a configuration directory for one run. lnav reads formats from <dir>/formats/<name>/*.json and settings from <dir>/configs/<name>/*.json:

docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" ghcr.io/randomcontainers/lnav \
  -I lnav-config -n -c ':set-min-log-level warning' app.log

lnav -i extra, which installs more formats from a git repository, needs git, which is not in the image.

What is in the image

  • lnav in /usr/local/bin, with its built-in log formats, its SQL functions and the terminal descriptions it needs for xterm, screen and tmux. With docker run -t, Docker sets TERM=xterm.
  • The distro's SQLite, PCRE2, libarchive, libcurl, libunistring, zlib and bzip2 libraries, which lnav is linked against. With libcurl, lnav also opens http:// and https:// URLs.
  • tzdata, for the timezone() SQL function and :set-file-timezone, and on Alpine bash, which runs lnav's converter scripts.

Not included:

  • PRQL queries. They need lnav's Rust extension, which the image leaves out, as the Debian and Alpine packages of lnav do; a PRQL query fails with "PRQL is not supported in this build". The extension also maps log messages to the source lines that wrote them and serves the external access API; the image has neither.
  • Following files on other hosts over ssh (lnav user@host:/var/log/syslog). The image has no ssh client. The release tarball also holds a prebuilt helper, src/tailer/tailer.ape, that lnav copies to the remote host for this; the build replaces it with an empty file, so lnav embeds no prebuilt program.
  • The pcap and OpenTelemetry Collector log formats, which convert their files with tshark and jq. Neither program is in the image, see Extending the slim image.

The configure options are in /usr/local/share/randomcontainers/lnav/buildinfo.

Default or slim

lnav's default image adds no other tools, so latest and slim are the same image, with the contents listed above. Use latest to run it and the slim tags as a base for your own image.

Tags

<version> is an lnav release such as 0.14.1. <minor> and <major> are its shorter forms, 0.14 and 0, and follow the newest release in that series. lnav has not had a 1.0 release, so <major> moves with every release, like latest. Each row lists the default tag and its slim twin, which point to the same image.

Tags Base
latest, slim Ubuntu
<version>, <version>-slim Ubuntu
<minor>, <minor>-slim, <major>, <major>-slim Ubuntu
ubuntu, slim-ubuntu Ubuntu
<version>-ubuntu, <version>-slim-ubuntu Ubuntu
<minor>-ubuntu, <minor>-slim-ubuntu, <major>-ubuntu, <major>-slim-ubuntu Ubuntu
<version>-ubuntu26.04, <version>-slim-ubuntu26.04 Ubuntu 26.04
alpine, slim-alpine Alpine
<version>-alpine, <version>-slim-alpine Alpine
<minor>-alpine, <minor>-slim-alpine, <major>-alpine, <major>-slim-alpine Alpine
<version>-alpine3.24, <version>-slim-alpine3.24 Alpine 3.24

The images are currently built on Ubuntu 26.04 and Alpine 3.24. Tags without a distro version move to the next distro release when the project does; tags ending in ubuntu26.04 or alpine3.24 stay on that release and are no longer rebuilt once the project moves to the next one. Every tag of the current lnav version, including the exact version, is rebuilt in place (see Updates), so pin a digest when you need the same bytes every time.

Platforms

linux/amd64 and linux/arm64, for both Ubuntu and Alpine. Both are compiled natively on GitHub-hosted runners, without emulation.

Files and permissions

The working directory is /work. The image runs as UID 1000, and any other UID works too: HOME is /cache for every user, and /cache can be written by anyone. How to get output files owned by you depends on how you run containers:

Runtime Flag
Docker on Linux (rootful), GitHub Actions --user "$(id -u):$(id -g)"
Rootless Podman --userns=keep-id
Rootless Docker --user 0:0 (root in the container is your user on the host)
Docker Desktop on macOS or Windows none, file ownership is mapped for you

lnav keeps its own files in /cache/.lnav and its temporary files in /tmp/lnav-user-<uid>-work, so it writes to /work only what you ask for, such as the file of :write-csv-to report.csv. lnav sets its umask to 027, so the files it writes have mode 0640 and other users cannot read them. lnav only reads the log files, so the logs can be mounted read-only with -v "$PWD:/work:ro".

lnav unpacks archives into /tmp/lnav-user-<uid>-work, and when an SQL query reads a gzip or bzip2 file, it writes an uncompressed copy of that file there as well. These files take space in the container until it is removed. For large compressed logs, mount a volume on /tmp, or use --tmpfs /tmp if they fit in memory.

Extending the slim image

Use a slim tag as the base for your own image. slim, slim-ubuntu and slim-alpine move to each new lnav release and are rebuilt when the base image changes. lnav also reads formats from /etc/lnav/formats/<name>/, so an image can carry yours. This example adds jq, which lnav needs to open OpenTelemetry Collector logs:

FROM ghcr.io/randomcontainers/lnav:slim-ubuntu@sha256:...
USER root
RUN apt-get update \
 && apt-get install -y --no-install-recommends jq \
 && rm -rf /var/lib/apt/lists/*
COPY myapp_log.json /etc/lnav/formats/myapp/
USER 1000:1000

On Alpine, start from slim-alpine and use apk add --no-cache jq. The entrypoint is ["tini", "--", "lnav"]; set your own ENTRYPOINT if your image runs something else. To pick up new lnav releases and base image fixes, let Dependabot or Renovate update the digest in your FROM line.

Everything the image adds is under /usr/local. /usr/local/share/randomcontainers/lnav/ holds the version, the source URL, the build options, the license files and runtime-deps, the list of distro packages lnav needs at run time.

Verifying

Each image has a build provenance attestation from this repository's GitHub Actions run, signed by the shared build workflow in randomcontainers/ci:

gh attestation verify oci://ghcr.io/randomcontainers/lnav:latest \
  --repo randomcontainers/lnav --signer-repo randomcontainers/ci

Images published since November 2026 also have a keyless cosign signature from the same workflow, for admission controllers that check cosign signatures. Tags last built before then have only the attestation.

cosign verify ghcr.io/randomcontainers/lnav:latest \
  --certificate-identity https://github.com/randomcontainers/ci/.github/workflows/build.yml@refs/tags/v1 \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-github-workflow-repository randomcontainers/lnav

Each platform image also carries an SPDX SBOM that lists every distro package with its version:

docker buildx imagetools inspect ghcr.io/randomcontainers/lnav:latest --format '{{ json .SBOM }}'

lnav is compiled here, so neither lnav nor the libraries in its source tree are in the SBOM, and image scanners do not check them. Its version is in /usr/local/share/randomcontainers/lnav/version.

lnav publishes no signatures or checksum files. The SHA-256 in package.yml is the digest GitHub records for the lnav-<version>.tar.gz release asset, and the build checks the tarball against it before compiling.

Updates

The project checks the releases of tstack/lnav every 15 minutes. Betas and release candidates are skipped. A release is picked up once it is 24 hours old. Its source tarball is checked against the digest GitHub records for the release asset, the new version and the tarball's SHA-256 are committed to package.yml, and the images are rebuilt. Only the newest release is built; tags of older versions stay as they were last built. A release that adds or removes a directory under src/third-party in lnav's source tree is built only after the license files here have been updated for it; until then its build stops and the existing tags stay as they are.

The images of the current version are also rebuilt when the Ubuntu or Alpine base image changes and at least every 7 days, so distro security fixes reach the current tags. After a release that changes src/third-party, new builds and these rebuilds pause until the license files have been updated.

Building

docker build -f Dockerfile.ubuntu --target slim \
  --build-arg VERSION=<version> \
  --build-arg SOURCE_SHA256=<sha256 from package.yml> \
  -t lnav:local .

Use Dockerfile.alpine for the Alpine image. --build-arg JOBS=<n> limits the number of parallel compile jobs.

Licenses

lnav is licensed under the BSD 2-Clause license; its source files carry the three-clause form of the same notice. lnav also contains code that lnav keeps in its source tree, under other terms:

  • Apache-2.0: notcurses, scnlib, digestible and the Result type, and fast_float in scnlib and rapidyaml, which is also offered under MIT and BSL-1.0.
  • MIT: fmt, pugixml, md4c, rapidyaml and the c4core and rng libraries inside it, robin_hood, date, ArenaAlloc, intervaltree, safe, ww898, short_alloc and the table of CSS color names.
  • BSD-3-Clause: CLI11, mapbox variant, the LRU cache, the timer code and the table of HTML entities from the WHATWG HTML standard.
  • BSD-2-Clause: base64, xxHash, is_utf8 and debugbreak in rapidyaml.
  • BSL-1.0: tlx, ring_span, mapbox's recursive_wrapper, inplace_function in rapidyaml and NanoRange in scnlib.
  • ISC: yajl.
  • Zlib: strnatcmp.
  • blessing: series.c and dbdump.c from SQLite.
  • CC-BY-SA-4.0: the table of xterm color names, from Jonas Jacek's 256 Colors Cheat Sheet.
  • CC0-1.0: the emoji table, and the expected type in scnlib, which is based on TartanLlama/expected.
  • Public domain: SpookyHash, the SHA-256 code, the string functions for SQLite, fts_fuzzy_match and the UTF-8 decoder in fmt.

k_merge_tree.h, a k-way merge template, and extension-functions.cc, the math and string functions for SQLite, name their authors but state no license. backward-cpp is in lnav's source tree but is not compiled into lnav. The terminal descriptions come from the ncurses terminfo database, which has no copyright notice of its own.

/usr/local/share/randomcontainers/lnav/licenses/ has lnav's LICENSE and NOTICES, which collects the license and copyright comments of the source files from other authors. The release tarball has no other license files. licenses/ in this repository has the texts it lacks: those of notcurses, scnlib and its bundled libraries, ArenaAlloc, base64, CLI11, intervaltree, mapbox variant, the LRU cache, the Result type, safe and the CSS color names, and the Apache-2.0, BSL-1.0 and BSD-3-Clause texts. LICENSE.xml-entities is the WHATWG license, which puts the HTML standard under CC BY 4.0 and the parts of it used in code, such as the entity table, under BSD-3-Clause. LICENSE.xterm-colors is the CC BY-SA 4.0 license of the xterm color table, and NOTICE.xterm-colors says where the table comes from. The image's license label is BSD-2-Clause AND BSD-3-Clause AND Apache-2.0 AND MIT AND BSL-1.0 AND ISC AND Zlib AND blessing AND CC-BY-SA-4.0 AND CC0-1.0 AND LicenseRef-Public-Domain. The Ubuntu and Alpine packages in the image keep their own licenses. The SBOM lists them.

The build changes no source file except src/tailer/tailer.ape, which it empties, and src/tailer/tailerbin.cc, which it generates again from the emptied file. /usr/local/share/randomcontainers/lnav/source has the upstream download URL of the tarball.

The files in this repository are available under the MIT license, see LICENSE, except the license texts in licenses/, which keep their own terms.

Requesting a tool

To suggest another tool, use the Request a tool form.

About

Auto-updating lnav (Logfile Navigator) images for amd64 and arm64

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors