Use <<'EOF'
(or <<\EOF
-- quoting only the first character will have the same effect) when starting your heredoc to prevent its expansions from being evaluated locally.
BTW, personally, I'd write this a bit differently:
#!/bin/sh -e
ssh "$1" bash <<'EOF'
{ read; read container _; } < <(docker ps)
docker stop "$container"
EOF
The first read
consumes the first line of docker ps
output; the second extracts only the first column -- using bash builtins only.