Ctrl-p and Ctrl-n behaving unexpectedly under Docker

前端 未结 1 1082
忘掉有多难
忘掉有多难 2021-02-05 09:08

For the life of me I can\'t seem to figure out why ctrl-p and ctrl-n don\'t work like they\'re supposed to under the Docker images I

1条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 10:00

    It looks like this has been removed (or moved) in the Docs, but it used to live here: https://docs.docker.com/engine/reference/commandline/attach/

    Edit: It looks like they reference the below in the Configuration Files documentation.

    The command sequence to detach from a docker container is ctrl-p ctrl-q, which is why ctrl-p doesn't work as expected. When you hit ctrl-p, docker is waiting on ctrl-q, so nothing happens.

    You can use the new --detach-keys argument to docker run to override this sequence to be 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 file to persist this change:

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

    More details on this can be found here: https://github.com/docker/docker/pull/15666 as I can't find it in the docs anymore.

    0 讨论(0)
提交回复
热议问题