emrearmagan/dockyard.nvim

github github
utility
stars 17
issues 0
subscribers 0
forks 1
CREATED

UPDATED


Dockyard.nvim

Interactive Docker dashboard directly in your editor. It lets you view and manage containers, images, networks, and logs

loglens

[!CAUTION] Still in early development, will have breaking changes!

Introduction

Dockyard provides a single Docker workspace inside Neovim. You can inspect containers, images, and networks, run common container actions, open shell sessions, and stream logs through LogLens without leaving the editor.

Features

  • Inspect and manage containers
  • Inspect and manage images
  • Inspect and manage networks
  • Open shell sessions inside containers
  • Stream and inspect logs
  • Navigate and search the file tree inside a container
  • Copy, modify, and manage files inside a container
  • Run Docker build commands from Dockyard

Requirements

Installation

lazy.nvim

{
  "emrearmagan/dockyard.nvim",
  dependencies = {
    "nvim-lua/plenary.nvim",
    "akinsho/toggleterm.nvim", -- optional
  },
  cmd = { "Dockyard", "DockyardFloat" },
  lazy = true,
  config = function()
    require("dockyard").setup({})
  end,
}

Configuration

[!tip] It's a good idea to run :checkhealth dockyard to see if everything is set up correctly.

require("dockyard").setup({
  loglens = {
    containers = {
      ["api"] = {
        _order = { "time", "level", "message" },
        format = function(entry)
          return {
            time = entry.timestamp and entry.timestamp:sub(12, 19) or "--:--:--",
            level = (entry.level or "info"):upper(),
            message = entry.message or "",
          }
        end,
        highlights = {
          { pattern = "%d%d:%d%d:%d%d", group = "Comment" },
          { pattern = "%f[%a]ERROR%f[^%a]", group = "ErrorMsg" },
        },
        sources = {
          {
            name = "Backend log1",
            path = "/var/log/app.json",
            parser = "json",
            tails = 200,
          },
          {
            name = "Backend log2",
            path = "/var/log/app2.json",
            parser = "json",
            tails = 200,
          },
        },
      },
      ["postgres"] = {
        sources = {
          {
            name = "Docker Logs",
            _order = { "logs" },
            parser = "text",
            format = function(line)
              return { logs = line }
            end,
          },
        },
      },
    },
  },
})

LogLens

loglens

Open LogLens from the containers tab with L. Each container can define one or more log sources.

Source options

  • name string (optional)
  • path string (optional; when set, logs are read from that file inside the container)
  • parser "json" | "text"
  • tails number (optional, default 100)

Container-level defaults (applied to all sources unless overridden):

  • _order string[] (optional column order)
  • format function (required at container level or source level; receives (entry, ctx))
  • highlights rules (optional)
  • max_lines number (optional, default 1000)
  • tails number (optional, default 100)

Text parser

For text parser, format receives (line, ctx).

{
  name = "Postgres Logs",
  parser = "text",
  _order = { "logs" },
  format = function(line, ctx)
    return {
      source = ctx.name or "-",
      logs = line,
    }
  end,
}

JSON parser

For JSON parser, format receives (entry, ctx) where ctx includes source metadata (name, path, parser).

{
  name = "Backend JSON",
  path = "/var/log/backend.json",
  parser = "json",
  max_lines = 2000,
  tails = 150,

  _order = { "time", "level", "message", "context" },
  format = function(entry, ctx)
    local ts = entry.timestamp and entry.timestamp:sub(12, 19) or "--:--:--"
    local level = (entry.level or "info"):upper()
    local ectx = entry.context or {}
    local user = ectx.user_id or "-"
    local trace = entry.trace_id or ectx.trace_id or "-"
    return {
      time = ts,
      level = level,
      source = ctx.name or "-",
      message = entry.message or "",
      context = string.format("user=%s trace=%s", user, trace),
    }
  end,
}

Highlight Rules

Rules use Lua patterns.

highlights = {
  { pattern = "%d%d:%d%d:%d%d", group = "Comment" },
  { pattern = "%f[%a]ERROR%f[^%a]", group = "ErrorMsg" },
  { pattern = "%f[%a]WARN%f[^%a]", group = "WarningMsg" },
  { pattern = "%f[%a]INFO%f[^%a]", group = "Identifier" },
  { pattern = "%d+%.%d+%.%d+%.%d+", group = "Special" },
  { pattern = "/api/[%w_/%-%.]+", color = "#8be9fd" },
}

Each rule supports:

  • pattern (required)
  • group (highlight group)
  • color (hex color)

Commands

  • :Dockyard - open fullscreen UI
  • :DockyardFloat - open floating UI

Keymaps

Main UI

Context Key Action
Global q Close Dockyard
Global R Refresh current tab
Global <Tab> / <S-Tab> Next / previous tab
Global j / k Move cursor
Global K Open details popup
Global ? Open help popup
Containers s Toggle start / stop
Containers x Stop container
Containers r Restart container
Containers d Remove container
Containers T Open shell
Containers L Open LogLens
Images <CR> Expand / collapse
Images d Remove image
Images P Prune dangling images
Networks <CR> Expand / collapse
Networks d Remove network

LogLens

Key Action
q Close LogLens
f Toggle follow
r Toggle raw mode
/ Set filter
c Clear filter
<CR> / K Open entry popup

License

MIT - see LICENSE.