Simplify my Docker workflow with Emacs


Up until a few weeks ago, I had never messed with Docker. Not that I had anything against it per se, but never before had I felt the need to isolate my work in containers that can be readily built up and torn down.

Docker and its helpful companion Docker Compose come with a rich command-line interface. Nonetheless, I don’t want to leave Emacs for simple tasks such as building a Docker image or preparing the containers with Docker Compose.

Fortunately, the Emacs ecosystem is ready to help. Four packages have improved my workflow with Docker:

The first two packages add syntax highlighting, completion and a bunch of useful key bindings to work with Dockerfile and docker-compose.yml.

The real magic, though, happens with docker-tramp. The beauty of interacting directly with the contents of a container is impressive. Combine docker-tramp with the handy completion of counsel and the power of Dired and you might feel like Henry Dorsett Case in his ecstatic hunt for the Neuromancer.

Through docker-tramp I can also run EShell on any available container and that is where eshell-bookmark shines. I just have to bookmark a remote EShell buffer and use counsel-bookmark to jump back to it. Managing containers hardly gets any faster than this.

A little advice if you use both counsel and eshell-bookmark: do not set counsel-bookmark-avoid-dired to t, otherwise selecting a bookmark with counsel-bookmark will take you to counsel-find-file instead of opening the desired EShell buffer.