Store output of docker run to bash variable

Hi,
I am trying to store the output of docker run into a bash variable. For example,
torch_version=$(echo "docker run -i --log-driver=none -a stdout --gpus all test-trt:latest python3 -c ‘import torch; print(torch.version)’ " | cut -d ' ' -f 10)
echo "PyTorch Version : $torch_version"
Output is: PyTorch Version : 1.9.1+cu111

However, when I try to do with torch_tensorrt,
trt_version=$(echo "docker run -i --log-driver=none -a stdout --gpus all test-trt:latest python3 -c ‘import torch; import torch_tensorrt; print(torch_tensorrt.version)’ " | cut -d ' ' -f 10)
I get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'torch_tensorrt'

On the other hand, if do
docker run -it --gpus all test-trt:latest bash
Then import torch_tensorrt, it works fine.

Thanks.