Oct 15,
2018

Docker Tip

Greetings Interweb surfers!

I'm using Docker more as a replacement of a virtual machine to compile packages in a clean environment than a containerization tool like it was designed, as for example a bare Docker Debian image is faster to download than the equivalent VirtualBox.

One thing that used to frustrate me was that sometimes, when attached to the console, the shell somewhat stopped and required an extra "enter" to continue. I never really paid close attention at what I was typing in those moments, my habit is to press Ctrl-p to browse the command history instead to reach for the cursor movement keys and that has become second nature to me that I do it without realizing.

It was driving me crazy.

(ノಠ益ಠ)ノ彡┻━┻

At first I thought I was unknowingly sending the flow-control stop signal, i.e. what's usually bound to the Ctrl-s combination1. It turned out I was way off target as Docker uses the Ctrl-p Ctrl-q keys sequence to detach from a running container's console.

So all I need was to put a saner sequence in the ~/.docker/config.json file, like the one I use below:

{
  "detachKeys": "ctrl-@,ctrl-q"
}

or remember to add the --detach-keys options when attaching to a container:

$docker start --detach-keys="ctrl-@,ctrl-q" -ai container_name

I can infer that all Docker developers either use the Vi shell binding or they reach for the cursor keys...


  1. at the time I tought it was some bizzarre interaction between the Bash running in Docker and my Zsh configuration ↩︎