在容器pod内,若是直接将域名记录到容器镜像的/etc/hosts文件是不行的,会是ip id这种形式,在1.7.x以及以上版本能够利用HostAliases来进行配置。
一、yaml配置:网络
hostAliases: - ip: "11.111.21.65" hostnames: - "yw01-01" - ip: "11.111.21.66" hostnames: - "yw02-01"
二、rancher配置:
在显示高级选项,找到网络,而后添加别名ide
注意:rancher里面这个主机名不能使用下划线,要使用标准域名。code
三、其它添加hosts方式:
yaml:CMD里面加 echo "xxxxxxxxxx" >> /etc/hosts ,可是容器里面的启动命令就要挪到外面来写
entrypoint等blog