Bug 1332570

Summary: detach keys doesn't work when configure escape keys into client configuration
Product: Red Hat Enterprise Linux 7 Reporter: Alex Jia <ajia>
Component: docker-latestAssignee: Antonio Murdaca <amurdaca>
Status: CLOSED NOTABUG QA Contact: atomic-bugs <atomic-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: dwalsh
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-05 12:33:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Alex Jia 2016-05-03 13:32:42 UTC
Description of problem:
It doesn't work when configure detachKey in ~/.docker/config.json.

Version-Release number of selected component (if applicable):
docker-latest-1.10.3-21.el7.x86_64

How reproducible:


Steps to Reproduce:
1. configure detachKey in ~/.docker/config.json
2. run a container in background
3. attach above running container w/ --config option

Actual results:

# cat ~/.docker/config.json 
{
    "detachKey": "ctrl-e,e"
}

# docker-latest run -itd docker.io/fedora:23 /bin/sh
28c0f37f95fd943221bcedb9dd7fe2250ffd585b18bbae2a8c5760ef2a82550d


# docker-latest --config=~/.docker/ attach 28c0f37f95fd943221bcedb9dd7fe2250ffd585b18bbae2a8c5760ef2a82550d
^e

NOTE: the container can't be detached.

Expected results:


Additional info:

In addition, there are questions in man page of docker-latest {run, start, exec, attach}.

1. '\\' is eaten in section --detach-keys of man page of docker-latest-{run, start, exec, attach}

2. no mentioned A-Z.

# man docker-latest-run|grep Override
          Override the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.

3. it seems 'shift+<character>' also works

Comment 2 Antonio Murdaca 2016-05-05 09:50:06 UTC
could you paste the content of ~/.docker/config.json? from your description it seems you're using 'detachKey' where instead you have to use 'detachKeys' (you're missing an 's')

Comment 3 Antonio Murdaca 2016-05-05 09:51:08 UTC
(In reply to Antonio Murdaca from comment #2)
> could you paste the content of ~/.docker/config.json? from your description
> it seems you're using 'detachKey' where instead you have to use 'detachKeys'
> (you're missing an 's')

alright you already pasted it. Indeed you're missing an 's' (it's 'detachKeys')

Comment 4 Antonio Murdaca 2016-05-05 09:59:36 UTC
I can reproduce a bug which is related to --config though

could you please try to omit --config and see if it works for you? because for me works fine.

Comment 5 Antonio Murdaca 2016-05-05 10:30:54 UTC
The problem here lies in the way flags and shell expansion is parsed:

Examples

if you do '--config ~/.docker/' everything works
if you do '--config=~/.docker/' everything does not work
if you do '--config="~/.docker/"' everything does not work
if you do '--config='~/.docker/'' everything does not work

So possibly we could try to deal with this upstream but I'm not sure it's doable.

the fix is to either remove the '=' so the shell can expand '~' or use an absolute path.

Comment 6 Antonio Murdaca 2016-05-05 10:43:07 UTC
reported upstream https://github.com/docker/docker/issues/22526

Comment 7 Daniel Walsh 2016-05-05 12:33:02 UTC
Antonio In your examples, this is just the way that shell expansion works.  Nothing to do with docker.  The docker client gets the expansion from the shell, docker should not do anything about it.

In stead of using docker, use echo 

echo '--config ~/.docker/'
--config ~/.docker/

echo --config ~/.docker/
--config /home/dwalsh/.docker/

echo --config= ~/.docker/
--config= /home/dwalsh/.docker/

echo --config = ~/.docker/
--config = /home/dwalsh/.docker/

...

Docker should not be expected to expand shell short cuts.

This should be closed as a not a bug

Comment 8 Alex Jia 2016-05-05 23:58:54 UTC
(In reply to Daniel Walsh from comment #7)
> Antonio In your examples, this is just the way that shell expansion works. 
> Nothing to do with docker.  The docker client gets the expansion from the
> shell, docker should not do anything about it.
> 
Daniel, I think it will be better if we can document this for users.

In addition, I also mentioned some document issues in Section Additional info, because it's trivial, I haven't file a separated bug.

Comment 9 Daniel Walsh 2016-05-06 00:01:50 UTC
Yes I am fine with documenting it.