I'm seeing some strange behaviour getting the output from docker run into a bash variable.
Simple example:
#!/bin/bash
PWD=$(docker run --rm -ti ubuntu pwd 2>&1)
# also tried with PWD=`docker run ...` with same behaviour
echo $PWD
echo abc $PWD
echo abc $PWD xyz
output
/
abc /
xyz/
The problem is on the last echo...
you need to modify the docker run --rm -ti ubuntu pwd 2>&1 with docker run --rm ubuntu pwd 2>&1
probabilly the interactive and tty mode doesn't work fine in a shell variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With