我从这里下载了CentOS Atomic Host,并将其安装在带有桥接适配器的VirtualBox VM中作为networking适配器。 默认安装,我只设置root密码,没有别的。 然后我login虚拟机,运行命令systemctl enable cloud-init来初始化我的实例并reboot 。 cloud-init的用户数据和元数据文件如下:
#meta-data | #user-data -------------------------------------------------------------------------------- instance-id: magicatomic | #cloud-config local-hostname: ss.magicatomic | groups: network-interfaces: | | - docker: [root] auto enp0s3 | write_files: iface enp0s3 inet static | - content: | address 192.168.1.110 | { network 192.168.1.0 | "debug": true, netmask 255.255.255.0 | "hosts": ["tcp://192.168.1.110:2375"] broadcast 192.168.1.255 | } gateway 192.168.1.1 | path: /etc/docker/daemon.json | runcmd: | - sudo systemctl daemon-reload | - sudo systemctl restart docker.service
但configuration是一半打破,这意味着:默认网关没有设置和协议未设置为静态在/etc/sysconfig/network-scripts/ifcfg-enp0s3当我做cat /etc/sysconfig/network-scripts/ifcfg-enp0s3我明白了
BOOTPROTO=none DEVICE=enp0s3 IPADDR=192.168.1.110 NETMASK=255.255.255.0 ONBOOT=yes TYPE=ethernet USERCTL=no
而当我做的route -n
Kernel IP Routing Table Destination Gateway Genmask Flags Metric Ref Use Iface 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
问题:没有设置默认网关
也许它只有25%被破坏…你的cloud-initconfiguration导致“BOOTPROTO = none”,这相当于“BOOTPROTO = static”更多信息在这些链接。
我仍然在寻找为什么没有设置默认网关。 你尝试删除该行吗? 我在审阅文档… http://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.html
更新:这似乎是一个已知的问题,并正在积极的工作。 跟踪此问题的错误是https://bugzilla.redhat.com/show_bug.cgi?id=1492726和https://bugs.launchpad.net/cloud-init/+bug/1686856
作为一个解决方法,我会build议添加一行到runcmd这样的事情nmcli con modify enp0s3 ipv4.gateway 192.168.1.1