手動部署:複製專案檔案、安裝 docker-compose 並執行
$ scp -r hello-docker user@remotehost:/path/to/src
$ ssh user@remotehost
$ pip install docker-compose
$ cd /path/to/src/hello-docker
$ docker-compose up -d
使用 DOCKER_HOST 環境變數設定目標引擎
$ cd hello-docker
$ DOCKER_HOST="ssh://user@remotehost" docker-compose up -d
使用 docker context
$ docker context create remote ‐‐docker "host=ssh://user@remotemachine"
remote
Successfully created context "remote"
$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST… unix:///var/run/docker.sock swarm
remote ssh://user@remotemachine
$ cd hello-docker
$ docker-compose ‐‐context remote up -d