I have a requirement to execute some commands on remote machine and i have written script like this on my local machine. 
Basically i'm getting docker images on my local machine and want to check whether those images are existing in remote server or not. 
I need to get non existing docker images (remote server) to my local machine. For that i have used below mentioned code, but it didn't work for me.
#!/bin/sh
declare array=$(docker images)
sshpass -p 'password' ssh -t username@1.2.3.4 << EOF
declare List=""
while read -r line; do
  if [ -z $(docker images -q $line) ]; then
    List="$List $line"
  else
    continue
  fi
done <<< "$array"
EOF
I want List variable to be in my local machine.
Can anyone help me on this issue?
Your help is much appreciated.
Best Regards.
 
     
     
    