私はswarmにデプロイするドッカースタックを作成しました。今私はちょっと混乱して、実際のサーバーにそれを配備するのに適切な方法がどのように見えますか?もちろんリモートドッカーホストに接続する/スタックをデプロイする
は私が
scp
ノードへの私の群れssh
のノードへの私のdocker-stack.yml
ファイルが- ランだから私は思っ
docker-machine
ツールがありますdocker stack deploy -c docker-stack.yml stackname
することができます。 私はあなたがTLSなしでポートを開く場合は動作するように思われるもの
docker-machine -d none --url=tcp://<RemoteHostIp>:2375 node1
を試してみましたか?私は次のことを受け :
$ docker-machine env node1
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.178.49:2375": dial tcp 192.168.178.49:2375: connectex: No connection could be made because the target machine actively refused it.
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
私はすでに証明書&を生成しようとしましたが、ホストにそれをコピー:
:ssh-keygen -t rsa
ssh-copy-id [email protected]
は、それから私は、次のような結果で
docker-machine --tls-ca-cert PathToMyCert --tls-client-cert PathToMyCert create -d none --url=tcp://192.168.178.49:2375 node1
を走りました
$ docker-machine env node1
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "node1:2375": There was an error reading certificate
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.
私はまた、汎用ドライバ私はTLSと正しくドッキングウィンドウマシンとリモートドッカホストを追加するにはどうすればよい
$ docker-machine create -d generic --generic-ssh-port "22" --generic-ssh-user "MyRemoteUser" --generic-ip-address 192.168.178.49 node1
Running pre-create checks...
Creating machine...
(node1) No SSH key specified. Assuming an existing key at the default location.
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Error creating machine: Error detecting OS: OS type not recognized
でそれを試してみましたか? スタックをサーバー/本番環境に展開するには、より良い方法がありますか?
ドッカーポートを公開してはいけませんが、それを行う方法は一度もありません。そして、私は彼らがこれを行う簡単な方法を提供していないと信じることはできません。
更新&ソリューション
私は両方の答えがそこに資格を持っていると思います。 私はDeploy to Azure Offical Docを見つけました(AWSでも同じです)。 @ Tarun Lalwaniからの答えは正しい方向に私を指摘し、それはほぼ公式の解決策です。それは私が彼の答えを受け入れた理由です。
は私のために次のコマンドが働いた:
ssh -fNL localhost:2374:/var/run/docker.sock [email protected]
次にあなたがいずれかを実行できます。
docker -H localhost:2374 stack deploy -c stack-compose.yml stackname
または
DOCKER_HOST=localhost:2374
docker stack deploy -c stack-compose.yml stackname
@BMitchからの回答も有効であり、セキュリティ彼が無視すべきではないと述べた懸念。
アップデート2
@bretfからの答えはあなたの群れに接続するための素晴らしい方法です。特に複数ある場合。それはまだベータですが、インターネットで利用可能で、ARMアーキテクチャを持っていないスウォームのために働きます。
コマンドは機能しませんが、正しい方向に向いています。私は[Docker Doku](https://docs.docker.com/docker-for-azure/deploy/#connecting-to-your-manager-nodes-using-ssh)を見つけました。私にとっては、 'ssh -p 22 -fNL localhost:2374:/var/run/docker.sock myuser @ node1'を' docker -H localhost:2374 ps'に設定するか 'DOCKER_HOST'を設定する – pr177
2375ポートを設定しようとしたとき私はあなたのドッカーデーモンの設定で既に '127.0.0.1:2375'を公開していると仮定しました。あなたはまだそれをしていなかったので、代わりにトラフィックをソケットにマップする必要がありました –