Ctrl-p and Ctrl-n behave unexpectedly under Docker

In life, I cannot understand why ctrl - p and ctrl - n do not work, as if they should be under the Docker images that I worked with. ctrl - p should work just like the up arrow, but I usually have to press it twice to get the last command that I ran. And it cycles through history in what seems random.

Maybe someone can help me figure this out.

docker run -it buildpack-deps:trusty # run a Linux based image root@74cbcf321fae :/# ls bin boot dev etc home lib lib64 ... root@74cbcf321fae :/# touch hello 

If I press up here, it should show the touch command, and then ls . If I press ctrl - p , nothing appears for the first time. When I click it again, ls appears magically.

Can someone help me figure this out. I can not live without ctrl - p and ctrl - n .

+5
source share
1 answer

It looks like this was deleted (or moved) in the Docs, but it lived here: https://docs.docker.com/engine/reference/commandline/attach/ p>

Change They appear to be linking to configuration files below.

The sequence of commands to disconnect from the docker container is: ctrl - p ctrl - q , so ctrl - p does not work as expected. When you press ctrl - p , dockers wait on ctrl - q , so nothing happens.

You can use the new argument --detach-keys for docker run to override this sequence as something other than ctrl - p :

 docker run -ti --detach-keys=" ctrl-@ " ubuntu:14.04 bash $# ls $# <--- Ctrl-P here will display ls now $# <--- Ctrl-@ here will detach from the running container 

If you want, you can add this to your ~/.docker/config.json to save this change:

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

More about this can be found here: https://github.com/docker/docker/pull/15666 , since I can no longer find it in the docs.

+11
source

Source: https://habr.com/ru/post/1263232/


All Articles