网络 - 如何在虚拟机centos7中为docker的container分配与宿主机同网段的固定IP
PHP中文网
PHP中文网 2017-04-24 09:11:49
0
2
591

本人菜鸟一枚,使用docker时遇到个问题,还望各位大神多多指点
操作环境:

虚拟机中的Centos7
    ip 10.1.2.249
    GW 10.1.2.254
docker 1.8
    建立container test1
利用的工具pipwork

期望給test1分配固定IP 10.1.2.248

已经进行的尝试有
1、 http://www.infoq.com/cn/articles/docker-network-and-pipework-open-source-explanation-practice 这篇文章中利用pipwork 分配固定IP的方法
2、http://www.xiaomastack.com/2015/02/06/docker-static-ip/ 这种脚本的方式

结果:container不能ping通局域网内其他机器,能ping通宿主机,通过tcpdump抓包,是container的mac地址发向路由,按照我个人了解应该是宿主机的mac发向路由,不知道跟我使用的centos是虚拟机是否有关,如果是的话 有没有好的方法解决这个问题。多谢

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
PHPzhong

Um, after experiments, there is no problem using pipwork on a physical machine. . . . . But if there is any expert who can solve this problem in the virtual machine, I hope you can give me some advice

洪涛

It is a bit troublesome to be on the same network segment as the host, but through the swarm + overlay network mode,
you can configure a good network for the containers to communicate with each other, and you can ping each other using the host name

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!