linux - `docker run` 在远程主机上

标签 linux docker

是否可以(直接使用 docker 命令或 docker-py API)从远程主机启动容器?

假设我有两台具有不同架构的机器: - A 是 x86机器 - B 是 ARM机器

我想使用我的 A 机器在 B 机器上运行一个容器。一开始我以为可以用这个命令:

[A]$> DOCKER_HOST=$MACHINE_B_IP:$MACHIN_B_PORT docker run hello-from-B

但是这个命令实际上拉取了图像 hello-from-B并尝试在机器 A 上运行它,最终结果为 exec format error因为很明显你不能运行特定于 ARM 的图像。到 x86机器。

机器 A 和 B 之间的通信运行良好。我可以运行 images 之类的命令或 ps它给了我预期的结果:

[A]$> DOCKER_HOST=$MACHINE_B_IP:$MACHIN_B_PORT docker images
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
hello-from-B              <none>              fd5059044831        13 hours ago        1.26GB

我听说过 docker-machine还没有尝试过,但据我了解,这并不能解决我的问题。

有什么方法可以使用 docker直接地。解决方法可能是使用 ssh连接到远程主机并使用 docker客户端直接从远程主机,但我想尽可能避免这种解决方案。

提前致谢,


TL;DR;

如何DOCKER_HOST=... docker run something运行 somethingDOCKER_HOST而不是在我的本地机器上运行它。

最佳答案

检查最新的 docker 18.09 是否包含该功能。
docker/cli PR 1014

Added support for SSH connection. e.g. docker -H ssh://me@server

  • The cli should accept ssh://me@server for DOCKER_HOST and -H. Using that would execute ssh with the passed config.
  • The ssh command would call a hidden command on the docker CLI binary on the remote side. For example, docker dial-stdio.

This command will make a connection to the local DOCKER_HOST variable (almost always the default local socket) and forward that connection on the commands stdio.
Even though this command is supposed to run locally to the dockerd binary, we think that it is an invalid configuration for this feature to remove the local docker binary so we can rely on it always being present.

How to verify it

docker -H ssh://me@server run -it --rm busybox

目前的 react :

From ops and sysadmins everywhere, we thank you for this fantastic and unexpected feature.
I'm hoping this will seriously cut down the number of times I see people opening dockerd TCP w/o TLS and just opt for SSH endpoints for remote mgmt.

关于linux - `docker run` 在远程主机上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44446472/

相关文章:

docker - Docker微型容器

java - 如何避免生成以太坊 DAG 进行测试?

linux - 当从 cron 调用脚本时,脚本中的 Sed 命令不起作用

linux - 从 docker registry 中拉取镜像时出错

linux - RPM 规范文件可以 "include"其他文件吗?

linux - 是否可以通过 procfs 确定进程打开了哪些 fds 用于读取和写入?

docker - 使用 docker-machine 设置 Swarm 时出现问题

linux - 如果日期字符串为 + 或 - 5 分钟,则

angular - Docker Angular 容器-热装

azure - Windows Nano Server 上的 Docker : There is not enough space on the disk