Skip to main content

Communication between containers

If data needs to be transferred between two running containers. The most convenient method is through ssh / scp perhaps rsync.

Accessing the network through a proxy

If the server cannot directly access the external network. Need to do itBefore any commands related to the networkConfigure Proxy:

export http_proxy=<http-proxy>
export https_proxy=<http-proxy>
export no_proxy=HyperAI-server-svc

Then proactively update it bayes Command line tools:

bayes upgrade

Create private key

bayes ssh create

Will be there ~/.ssh Create a stack named HyperAI / HyperAI.pub The private and public keys. And will HyperAI.pub Upload to HyperAI of key In the list.

ssh The protocol defaults to accessing ~/.ssh/id_rsa / ~/.ssh/id_rsa.pub , The two files generated above can be re commanded. Can eliminate subsequent input -i ~/.ssh/hyperai.

mv ~/.ssh/hyperai ~/.ssh/id_rsa
mv ~/.ssh/hyperai.pub ~/.ssh/id_rsa.pub

First, log in to the target container, open Terminal Execute the following content:

# If a proxy is required to access the external network
# Export http_proxy=<http-proxy>
# Export https_proxy=<http-proxy>
# Export no_proxy=HyperAI-server-svc

apt install iproute2 -y
ip a

The following results can be obtained:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
4: eth0@if96: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1440 qdisc noqueue state UP group default
link/ether 2a:d7:3a:68:13:ee brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.38.6.87/32 scope global eth0
valid_lft forever preferred_lft forever

You can see the internal network of the container ip by 10.38.6.87, By command ssh -i ~/.ssh/hyperai 10.38.6.87 You can access the container now. At the same time, this method can also support rsync.