如何使用默认网桥网络允许Docker主机在所有端口上返回到容器的所有通信?

时间:2019-07-31 21:16:46

标签: docker networking containers host bridge

ROS Docker网络问题

目标是创建一个或多个指定运行一个或多个ROS节点的docker容器。分布式ROS网络预计将在docker容器以及主机上的运行节点上运行。每个Docker容器都需要一个单独的IP地址。无法将节点从容器roslaunch到主机操作系统。

我的问题的重点是网络,目标是ROS并不重要。

可疑问题可能在于docker限制访问容器的安全性/ NAT规则。

工作

    节点到节点的通信通过几种方式起作用。特别是在[1]中使用docker-compose并使用显式的ROS_IP和ROS_MASTER_URI。
  1. 在主机和容器之间执行ping操作。
  2. 在容器与容器之间执行ping操作。
  3. 从容器到主机的ssh

失败

  1. netcat监听容器中的端口;主机上的netcat端口
  2. 启动到特定计算机(主机)
  3. 从默认网络上的容器到主机用户@本地主机的SSH(拒绝连接)

网络类型

  1. 默认docker
  2. 自定义泊坞桥
  3. 具有分配的IP地址的Linux网桥
  4. Macvlan(无法作为默认行为与主机通信-尚未进行深入调查)

roslaunch错误

注意:不提供敏感信息。

containeruser@ea0df2d4e654:~/catkin_ws$ roslaunch basic_class_design file1.launch 
... logging to /home/containeruser/.ros/log/fcc9757a-b39b-11e9-beb7-02420a00be04/roslaunch-ea0df2d4e654-2582.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://10.0.190.4:35539/
remote[10.0.190.0-0] starting roslaunch
remote[10.0.190.0-0]: creating ssh connection to 10.0.190.0:22, user[hostuser]
/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: FutureWarning: CTR mode needs counter parameter, not IV
  self._cipher = factory.new(key, *args, **kwargs)
launching remote roslaunch child with command: [env ROS_MASTER_URI=http://10.0.190.4:11311 /opt/ros/kinetic/env.sh roslaunch -c 10.0.190.0-0 -u http://10.0.190.4:35539/ --run_id fcc9757a-b39b-11e9-beb7-02420a00be04]
remote[10.0.190.0-0]: ssh connection created

SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.14

MACHINES
 * hostcomputer

NODES
  /
    rviz_ea0df2d4e654_2582_1858054397354533661 (rviz/rviz)

auto-starting new master
process[master]: started with pid [2595]
ROS_MASTER_URI=http://10.0.190.4:11311

setting /run_id to fcc9757a-b39b-11e9-beb7-02420a00be04
process[rosout-1]: started with pid [2608]
started core service [/rosout]
[10.0.190.0-0]: launching nodes...
[10.0.190.0-0]: ROS_MASTER_URI=http://10.0.190.4:11311
[10.0.190.0-0]: process[rviz_ea0df2d4e654_2582_1858054397354533661-1]: started with pid [21035]
[10.0.190.0-0]: ... done launching nodes
[10.0.190.0-0]: [rviz_ea0df2d4e654_2582_1858054397354533661-1] process has died [pid 21035, exit code -6, cmd /opt/ros/kinetic/lib/rviz/rviz __name:=rviz_ea0df2d4e654_2582_1858054397354533661 __log:=/home/hostuser/.ros/log/fcc9757a-b39b-11e9-beb7-02420a00be04/rviz_ea0df2d4e654_2582_1858054397354533661-1.log].
log file: /home/hostuser/.ros/log/fcc9757a-b39b-11e9-beb7-02420a00be04/rviz_ea0df2d4e654_2582_1858054397354533661-1*.log
[10.0.190.0-0]: all processes on machine have died, roslaunch will exit
remote[10.0.190.0-0]: [rviz_ea0df2d4e654_2582_1858054397354533661-1] process has died [pid 21035, exit code -6, cmd /opt/ros/kinetic/lib/rviz/rviz __name:=rviz_ea0df2d4e654_2582_1858054397354533661 __log:=/home/hostuser/.ros/log/fcc9757a-b39b-11e9-beb7-02420a00be04/rviz_ea0df2d4e654_2582_1858054397354533661-1.log].
log file: /home/hostuser/.ros/log/fcc9757a-b39b-11e9-beb7-02420a00be04/rviz_ea0df2d4e654_2582_1858054397354533661-1*.log

[10.0.190.0-0] process has died
remote[10.0.190.0-0]: unable to contact [10.0.190.0] to shutdown cleanly. The remote roslaunch may have exited already.
^C[rosout-1] killing on exit
[master] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
done

带有Netcat的TCP转储

tcpdump: listening on br0, link-type EN10MB (Ethernet), capture size 262144 bytes
2019-07-31 10:11:12.236156 IP (tos 0x0, ttl 64, id 15524, offset 0, flags [DF], proto TCP (6), length 60)
    10.0.190.0.56818 > 10.0.190.4.1234: Flags [S], cksum 0x9033 (incorrect -> 0xc062), seq 1635619556, win 29200, options [mss 1460,sackOK,TS val 2207296 ecr 0,nop,wscale 7], length 0
2019-07-31 10:11:12.236192 IP (tos 0x0, ttl 64, id 33639, offset 0, flags [DF], proto TCP (6), length 40)
    10.0.190.4.1234 > 10.0.190.0.56818: Flags [R.], cksum 0x48a4 (correct), seq 0, ack 1635619557, win 0, length 0
2019-07-31 10:11:17.241132 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.190.4 tell 10.0.190.0, length 28
2019-07-31 10:11:17.241153 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 10.0.190.0 tell 10.0.190.4, length 28
2019-07-31 10:11:17.241155 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.190.0 is-at 86:86:c3:9e:6a:93, length 28
2019-07-31 10:11:17.241157 ARP, Ethernet (len 6), IPv4 (len 4), Reply 10.0.190.4 is-at 02:42:0a:00:be:04, length 28

参考

0 个答案:

没有答案