I'm trying to assign container names to an array.
The command works perfectly when I'm running it without assigning to an array:
ARR=docker network inspect --format '{{ range $key, $value := .Containers }}{{ printf "%s\n" $value.Name}}{{ end }}' some_network $$ echo $ARR I'd like to do same thing but over SSH:
ssh [email protected] " ARR=( $(docker network inspect --format '"'{{ range $key, $value := .Containers }}{{ printf "%s\n" $value.Name}}{{ end }}'"' some_network) ) && echo $ARR " but it complains:
Template parsing error: template: :1: unexpected unclosed action in command I guess the reason lies in string interpolation or escaping ', can u give any advice guys?
echo $ARRis equivalent toecho ${ARR[0]}, you'll only see the first element.echo $ARRin a double-quoted string, so your local shell will expand those before launching ssh