create —context compose

Source

  • when using SSH no additional configuration is required on the remote host and the connection is secure by default
  • also, your ~/.ssh/config is respected so that you can use the hosts defined there without having to specify the user, port, identity file, etc.
$ docker context create remote-host --docker ssh://my-host
$ docker --context remote-host ps -a
...

(this expects a properly configured host named my-host in your ~/.ssh/config)

  • for better convenience, create an alias so that you can easily use the context with compose commands as well
$ echo 'alias docker-rh="docker --context remote-host"' >> ~/.bash_rc
$ . ~/.bash_rc
$ docker-rh compose ps -a
...