File path with space as variable in bash script
It's not a problem with variable assignment, you're doing it correctly. It's how you're using it.
This:
my_path = "/some/path with/space"
docker run --rm --mount source=$my_path,target=$some_other_path,type=bind …
Will, after substitution, become this:
docker run --rm --mount source=/some/path with/space,target=/some/other/path,type=bind …
You need to quote the argument to the docker
command during invocation:
docker run --rm --mount "source=$my_path,target=$some_other_path,type=bind" …
Alternatively quote just the variable. Bash merges adjacent strings, quoted or not.
docker run --rm --mount source="$my_path",target=$some_other_path,type=bind …