容器在启动之后,如果需要容器的/etc/hosts 去绑定其它域名与IP的,我总结了docker,compose,k8s的实现方式 ,总结如下
docker run
docker run --add-host=kafka1:192.168.1.10
docker-compose
extra_hosts:
- "kafka1:192.168.1.10"
- "kafka2:192.168.1.11"
k8s
kind: Deployment
apiVersion: apps/v1
spec:
template:
spec:
hostAliases:
- ip: "192.168.1.10"
hostnames: ["kafka1"]
- ip: "192.168.1.11"
hostnames: ["kafka2"]