Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker change Ctrl+p to something else?

Tags:

docker

I am using docker run /bin/bash to develop my container and every time I want to use Ctrl+p in a terminal or in emacs, I have to type it twice, since docker uses it to detach from a container (Ctrl+p Ctrl+q).

How can I change Ctrl+p to something else more convenient that is not used in emacs or in a terminal setting?

like image 744
719016 Avatar asked Dec 29 '13 18:12

719016


People also ask

What happens when you press ctrl P Q inside of container in docker?

You have to use two combinations, one after the other: ctrl+p followed by ctrl+q. You turn interactive mode to daemon mode, which keeps the container running but frees up your terminal. You can attach to it later using docker attach, if you need to interact with the container more.

How do I stop docker Ctrl C?

In both cases, the docker container acts as if it simply ignores Ctrl-C. Starting with docker 0.6. 5 , you can add -t to the docker run command, which will attach a pseudo-TTY . Then you can type Control-C to detach from the container without terminating it.

What is stdin and stdout in docker?

In general they are same as what you have mentioned and read in reference links for python. streams for receiving or reading input (stdin) and printing output (stdout). Example input from the keyboard or printing output to unix terminal. one reference here.


1 Answers

Docker has a configuration file and you can change the detach binding by adding

{     "detachKeys": "ctrl-z,z" } 

to ~/.docker/config.json.

If there are other entries in config.json then just add the "detachKeys" entry as the last one. For example:

{     "HttpHeaders": {         "User-Agent": "Docker-Client/19.03.11 (linux)"     },     "detachKeys": "ctrl-z,z" } 

Note: If you are running docker using sudo docker ... the .docker directory with the configuration file must be in the root's home directory (i.e., /root/.docker/config.json).

like image 160
creack Avatar answered Oct 20 '22 20:10

creack