Open Super-long opened 3 years ago
在example/counter/run_xxx.sh和example/block/run_xxx.sh中IP变量的获取是执行如下语句hostname -i | awk '{print $NF}'。
example/counter/run_xxx.sh
example/block/run_xxx.sh
hostname -i | awk '{print $NF}'
容器的网络模式默认是bridge,在这种模式下容器启动后会通过DHCP获取一个地址,这就导致hostname -i会生成两项,导致在宿主机中使用了容器生成的虚拟网卡,从而导致执行样例失败:
hostname -i
现在的问题是如何优雅的解决这个问题,如果IP的获取不通过shell,而使用C++,这种问题很好解决,我们只需要跑自连接,成功当前环境就是宿主机,否则就是容器环境。但是是否有方法在不改变现有获取配置的方法的情况下解决这个问题。
在
example/counter/run_xxx.sh
和example/block/run_xxx.sh
中IP变量的获取是执行如下语句hostname -i | awk '{print $NF}'
。容器的网络模式默认是bridge,在这种模式下容器启动后会通过DHCP获取一个地址,这就导致
hostname -i
会生成两项,导致在宿主机中使用了容器生成的虚拟网卡,从而导致执行样例失败:现在的问题是如何优雅的解决这个问题,如果IP的获取不通过shell,而使用C++,这种问题很好解决,我们只需要跑自连接,成功当前环境就是宿主机,否则就是容器环境。但是是否有方法在不改变现有获取配置的方法的情况下解决这个问题。