Reputation: 7441
I'm trying to use docker exec with OpenSSL and piping like this. I have a container thats running called test1.
1. openssl genrsa -des3 -passout pass:123 2048 | docker exec -i test1 sh -c 'cat >/key.pem
2. docker exec test1 cat key.pem
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,DE60A9F33B9E508D
/uJYBfM6YwCkIgrgQSH......
3. docker exec test1 cat key.pem | openssl req -subj '/CN=client' -new -key -out client.csr -passin pass:123
write /dev/stdout: broken pipe
If I run these commands without using docker they work OK. Is/does docker do anything different with the stdin and stdout streams ?
Upvotes: 1
Views: 1760
Reputation: 3683
You should be able to fix this by doing two things:
docker exec -t test1 cat key.pem
|
starts. Simply change the overall command to something that makes this clear to bash, this should work docker exec -t test1 cat key.pem | openssl req -subj '/CN=client' -new -key /dev/stdin -passin pass:123
Upvotes: 2