将文件从一个docker容器复制到另一台主机上的另一个容器的最佳方法是什么?我们在尝试这样做时遇到了几个问题。
问题#1:我们提供了一个覆盖网络并将容器连接到它。创建容器时,容器可以使用IP地址相互ping,但不使用使用-h标志提供的主机名
容器1:
root@rca-ord:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.29.10 rca-ord
root@ica-ord:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.29.11 ica-ord
使用主机名ping失败
root@ica-ord:/# ping rca-ord
ping: unknown host rca-ord
使用IP地址ping有效
root@ica-ord:/# ping 10.0.29.10
PING 10.0.29.10 (10.0.29.10) 56(84) bytes of data.
64 bytes from 10.0.29.10: icmp_seq=1 ttl=64 time=0.684 ms
64 bytes from 10.0.29.10: icmp_seq=2 ttl=64 time=0.434 ms
64 bytes from 10.0.29.10: icmp_seq=3 ttl=64 time=0.731 ms
64 bytes from 10.0.29.10: icmp_seq=4 ttl=64 time=0.672 ms
64 bytes from 10.0.29.10: icmp_seq=5 ttl=64 time=0.545 ms
64 bytes from 10.0.29.10: icmp_seq=6 ttl=64 time=1.25 ms
^C
--- 10.0.29.10 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5010ms
rtt min/avg/max/mdev = 0.434/0.719/1.251/0.258 ms
看起来我们需要运行一些DNS服务器。怎样详情是什么?
root@ica-ord:/# scp 10.0.29.10:test-file.txt .
The authenticity of host '10.0.29.10 (10.0.29.10)' can't be established.
ECDSA key fingerprint is SHA256:Bdnjhvxlk1ILzWpa8tvu+YLaHRqh9XBftIoeLSpKLBQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.29.10' (ECDSA) to the list of known hosts.
root@10.0.29.10's password:
我们认为应该有一种简单的方法在多台主机上的容器之间复制文件。有吗?