I would like to pass the variable
$styled to a script inside a docker container.
The docker command would look something like
docker exec container_name "/bin/bash -c cd /where/the/script/is && ./echo.sh $styled"
echo.sh would look like this
#!/bin/bash echo -e $1
$styled contains escape characters, so lets say it is:
On my local computer i can pass the variable to a local echo.sh without any issues, unfortunately it doesn’t work while using dockers exec.
the error message is something like:
./echo.sh x1b[7mFF1SOME_TEXTx1b[27m: no such file or directory": unknown
I am pretty sure it has to do with how escaping works, single quotes, double quotes and so on, but I am simply confused by all those layers.
I also tried:
docker exec container_name "/bin/bash -c 'cd /where/the/script/is && ./echo.sh '$P'"
which results in
stat /bin/bash -c 'cd /where/the/script/is && ./echo.sh 'x1b[7mSOME_TEXTx1b[27m': no such file or directory"
Source: Docker Questions