As a developer working on complex projects with lots of services, managing the docker containers with super long commands from the CLI can be very tedious.

Few weeks ago, one of my colleagues (Philipp Sauter a passionate Go developer) showed me an amazing tool to manage Docker. It is called lazydocker and it sped up both my understanding of docker and my development speed.

Once you installed it, you can just run lazydocker and you should see something like this:

Top 5 most useful features

Help

First, the most useful feature is the contextual help to indicate which action you can do depending on which line is active. To see the help, press ?

With services
With containers

Execute bash in the container

Executing bash in a docker container requires a command like docker exec -it <container> /bin/bash (if you actually remember the name of the container, which is not my case). Or you can just type E in lazydocker while selecting the container.

See the logs of the instance

Accessing the logs of a running service or container is super simple, just type m and you will see the logs with the follow option activated (new logs will appear while being produced).

Bulk option

At work, we use docker compose and therefore, I use the b on a daily basis to manage all my docker compose components at once. My favorite command is the down with volumes and images which allows to restart clean and be sure that your state is even with what you'll be shipping.

All the bulk options

Customisation

If you like to customise your tools, lazydocker lets you do that: you can configure almost everything.
Here is the default config:

gui:
  scrollHeight: 2
  language: 'auto' # one of 'auto' | 'en' | 'pl' | 'nl' | 'de' | 'tr'
  theme:
    activeBorderColor:
    - green
    - bold
    inactiveBorderColor:
    - white
    optionsTextColor:
    - blue
  returnImmediately: false
  wrapMainPanel: false
commandTemplates:
  dockerCompose: docker-compose
  restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
  stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
  serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
  viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
  rebuildService: '{{ .DockerCompose }} up -d --build {{ .Service.Name }}'
  recreateService: '{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}'
  viewContainerLogs: docker logs --timestamps --follow --since=60m {{ .Container.ID
    }}
  containerLogs: docker logs --timestamps --follow --since=60m {{ .Container.ID }}
  allLogs: '{{ .DockerCompose }} logs --tail=300 --follow'
  viewAlLogs: '{{ .DockerCompose }} logs'
  dockerComposeConfig: '{{ .DockerCompose }} config'
  checkDockerComposeConfig: '{{ .DockerCompose }} config --quiet'
  serviceTop: '{{ .DockerCompose }} top {{ .Service.Name }}'
customCommands:
  containers:
  - name: bash
    attach: true
    command: "docker exec -it {{ .Container.ID }} /bin/sh -c 'eval $(grep ^$(id -un): /etc/passwd | cut -d : -f 7-)'"
    serviceNames: []
oS:
  openCommand: open {{filename}}
  openLinkCommand: open {{link}}
update:
  dockerRefreshInterval: 100ms
stats:
  graphs:
  - caption: CPU (%)
    statPath: DerivedStats.CPUPercentage
    color: blue
  - caption: Memory (%)
    statPath: DerivedStats.MemoryPercentage
    color: green

Conclusion

First, Lazydocker helped me to get a deeper understanding of the different concepts of Docker (images, volumes, containers, services). Then, because the contextual help is so good and the features so useful, I adopted the tool in no time and I advice you to do the same!

Useful links: Shortcuts, Configuration, Readme