Normally, Ctrl-p is a shortcut for navigating previously used commands in shell. Unfortunately, inside docker, Ctrl-p Ctrl-q is a sequence to detach from a Docker container, so Ctrl-p becomes overridden. In such case, one has to press Ctrl-p twice to navigate to a previous command (kind of annoying).

To get rid of this behavior:

Step 1: Create a file ~/.docker/config.json (it did not exist in my case).

Step 2: Inside config.json, put the following:

    "detachKeys": "ctrl-@",

Step 3: Restart docker service (sudo service docker restart on Ubuntu)