LazyDocker Terminal UI

LazyDocker cheatsheet — manage Docker containers, images, volumes with a terminal UI. Keyboard shortcuts for viewing logs, exec, stats, prune. Interactive Docker management.

4 min read

What it is

LazyDocker is a terminal UI for Docker and Kubernetes, providing a quick overview and management of containers, images, volumes, networks, and more.

Installation

Linux

sudo apt-get update && sudo apt-get install lazy-docker
# Or using Homebrew
brew install lazy-docker

macOS

brew install lazy-docker

Windows

LazyDocker is not directly installable on Windows. The recommended approach is to use the Windows Subsystem for Linux (WSL) and follow the Linux installation instructions within your WSL distribution.

Core Concepts

  • Containers: Running instances of Docker images. LazyDocker allows you to view, start, stop, restart, remove, and prune containers.
  • Images: Read-only templates used to create containers. LazyDocker lets you list, pull, remove, and prune images.
  • Volumes: Persistent storage for Docker containers. LazyDocker helps manage volumes, including creating, removing, and inspecting them.
  • Networks: Virtual networks that containers can connect to. LazyDocker shows available networks and allows their management.
  • Services (Docker Swarm): Managed applications running as a set of tasks. LazyDocker provides an overview of services and their state.
  • Pods (Kubernetes): The smallest deployable units in Kubernetes, representing a group of one or more containers. LazyDocker displays pods, their status, and associated events.
  • Deployments (Kubernetes): Objects that describe the desired state for Pods and ReplicaSets. LazyDocker shows deployment status and allows scaling.
  • Nodes (Kubernetes): The machines (physical or virtual) that run your cluster. LazyDocker displays node status and resource utilization.

Commands / Usage

LazyDocker is primarily navigated and controlled via its interactive interface. The following are key bindings and actions within the UI:

General Navigation and Actions

  • ?: Show help menu with keybindings.
  • Ctrl+W: Close current tab.
  • Ctrl+N: Open a new tab.
  • Ctrl+L: Refresh all data.
  • Tab: Switch between panels (e.g., containers list, logs, details).
  • Up/Down Arrow: Navigate lists.
  • Enter: Select an item or open a subcommand.
  • q: Quit LazyDocker.
  • :: Enter command mode for executing shell commands.

Docker Contexts

  • c: Show Docker containers.
  • i: Show Docker images.
  • v: Show Docker volumes.
  • n: Show Docker networks.
  • s: Show Docker Swarm services.
  • d: Show Docker daemon logs.
  • k: Show Kubernetes contexts.

Kubernetes Contexts

  • p: Show Kubernetes pods.
  • d: Show Kubernetes deployments.
  • s: Show Kubernetes services.
  • n: Show Kubernetes namespaces.
  • no: Show Kubernetes nodes.
  • po: Show Kubernetes persistent volume claims (PVCs).
  • ev: Show Kubernetes events.
  • sec: Show Kubernetes secrets.
  • ing: Show Kubernetes ingress.

Container Management (when viewing containers)

  • r: Restart selected container.
  • s: Stop selected container.
  • t: Start selected container.
  • k: Kill selected container.
  • rm: Remove selected container.
  • a: Attach to selected container.
  • l: View logs for selected container.
  • e: Execute command in selected container.
  • cp: Copy files to/from selected container.
  • ex: Execute command in selected container.

Image Management (when viewing images)

  • rmi: Remove selected image.
  • pull: Pull selected image.
  • prune: Remove unused images.

Volume Management (when viewing volumes)

  • rm: Remove selected volume.
  • prune: Remove unused volumes.

Network Management (when viewing networks)

  • rm: Remove selected network.

Kubernetes Pod Management (when viewing pods)

  • rm: Delete selected pod.
  • l: View logs for selected pod.
  • exec: Execute command in a pod.
  • describe: Show detailed description of the pod.

Kubernetes Deployment Management (when viewing deployments)

  • scale: Scale selected deployment.
  • restart: Restart selected deployment.
  • delete: Delete selected deployment.

Common Patterns

Quick Restart of a specific Docker container:

  1. Open LazyDocker: lazydocker
  2. Press c to view containers.
  3. Navigate to the desired container using arrow keys.
  4. Press r to restart it.

Executing a command inside a running Docker container:

  1. Open LazyDocker: lazydocker
  2. Press c to view containers.
  3. Navigate to the desired container.
  4. Press e to open the command execution prompt.
  5. Type the command (e.g., ls -l /app) and press Enter.

Viewing logs of a Kubernetes pod:

  1. Open LazyDocker: lazydocker
  2. Press p to view pods.
  3. Navigate to the desired pod.
  4. Press l to view its logs. Use arrow keys to scroll.

Pruning unused Docker images:

  1. Open LazyDocker: lazydocker
  2. Press i to view images.
  3. Press Shift+P (or P depending on version/configuration) to prune unused images.

Scaling a Kubernetes deployment:

  1. Open LazyDocker: lazydocker
  2. Press d to view deployments.
  3. Navigate to the desired deployment.
  4. Press s to open the scaling prompt.
  5. Enter the new replica count and press Enter.

Gotchas

  • Context Switching: LazyDocker often defaults to the docker context. If you’re working with Kubernetes, ensure you’ve switched to the correct Kubernetes context either before launching LazyDocker or by using the Kubernetes context switching options within the UI.
  • Permissions: On some Linux systems, you might need to run lazydocker with sudo if your user is not part of the docker group. However, it’s generally recommended to add your user to the docker group for easier access: sudo usermod -aG docker $USER. You’ll need to log out and log back in for this change to take effect.
  • Kubernetes Resource Limits: LazyDocker displays Kubernetes resources, but it doesn’t magically bypass resource limits or quotas defined in your cluster.
  • Keybinding Conflicts: If you’re using a terminal multiplexer like tmux or screen, some keybindings might conflict. You may need to configure LazyDocker or your multiplexer to avoid these conflicts.
  • Performance with Many Resources: If you have a very large number of containers, images, or Kubernetes resources, LazyDocker might take longer to load and display data initially.