Docker image, no prompt when call in a subshell

mickael
mickael
Community Member

Hi,

As encouraged by @graham_1P, I try to switch to the docker image.

I replaced the op binary in /usr/local/bin by the following script:

#!/bin/bash
docker run --rm -it -v $HOME/.op:/home/opuser/.op 1password/op op $@

Things are working fine when I call the script directly from my terminal.

However, I have some issues when I try to call it from a subshell.

For example, the following call:

echo "$(op signin my_team --output=raw)"

which is equivalent of

 echo "$(docker run -it --rm  -v $HOME/.op:/home/opuser/.op 1password/op op signin my_team --output=raw)"

doesn't display the password prompt.

Does someone have an idea on how to resolve this ?

Thanks,


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided

Comments

  • felix_1p
    felix_1p
    1Password Alumni

    Hi @mickael,

    I investigated the issue a little bit and while I'm not very familiar with docker, I believe this is due to how docker connects the process to stdin, stdout and stderr. It almost looks like any output created by the CLI (be it writing to stdout, stderr or directly to /dev/tty) is written to stdout of the docker process, but also not.

    I created a simple Go app that replicates the password prompt from the CLI. In particular: writing a prompt to /dev/tty or stderr, waiting for input on stdin and writing that input to stdout.

    Here are the invocations that I tried (<input here> is where the process waited and accepted hidden input):

    $ docker run -it --rm test-app
    test prompt: <input here>
    entered data: asdf%
    
    $ echo $(docker run -it --rm test-app)
    <input here>
    entered data: asdf
    
    $ docker run -it --rm test-app > test
    <input here>
    $ cat test
    test prompt:
    entered data: asdf% 
    

    Lets go through those:

    1. "Normal" invocation, you said it works and it does.
    2. No prompt, but input is accepted and only what I print to stdout is echoed.
    3. No prompt, but input is accepted and everything, including the prompt, is written to the file

    I'm almost more confused about how things work with docker than before, but maybe I'm completely missing something about the standard file descriptors...

    So, while you can't see the prompt, it should still accept the password and work in a subshell? But if you redirect the output in any other way it may not work.

    I will open a ticket for us to investigate this further. If anyone has a better idea of what's going on here, I'm all ears :)

This discussion has been closed.