简体   繁体   English

如何更改 OpenShift pod 中的 /etc/resolv.conf 文件

[英]How to change /etc/resolv.conf file in an OpenShift pod

I have a docker image I deployed onto OpenShift (using oc new-app).我有一个部署到 OpenShift 上的 docker 镜像(使用 oc new-app)。 However, it's not working properly because of a missing dns search entry in /etc/resolv.conf.但是,它无法正常工作,因为 /etc/resolv.conf 中缺少 dns 搜索条目。 When I create a container from my docker image and run it, I can specify the parmater --dns-search.当我从我的 docker 镜像创建一个容器并运行它时,我可以指定参数 --dns-search。

How can I do something similar during the deployment of my image onto OpenShift with oc new-app?在使用 oc new-app 将我的图像部署到 OpenShift 的过程中,我如何做类似的事情?

You can edit the config Map of Node in master server您可以在主服务器中编辑节点的配置映射

# oc get cm -n openshift-node

for all compute nodes edit the config map by below command.( Only need to perform in master server)对于所有计算节点,通过以下命令编辑配置映射。(只需要在主服务器上执行)

#  oc edit cm node-config-compute  -n openshift-node

......
dnsBindAddress: 127.0.0.1:53
    dnsDomain: cluster.local
    dnsIP: 10.0.80.11
    dnsNameservers: null
    dnsRecursiveResolvConf: /etc/origin/node/resolv.conf
.......

Edit dnsIP section with your DNS IP.使用您的 DNS IP 编辑 dnsIP 部分。 Then restart the service然后重启服务

# systemctl restart atomic-openshift-node.service

The DNS ip will be prepended in all /etc/resolv.conf file of Pods. DNS ip 将被添加到 Pod 的所有 /etc/resolv.conf 文件中。

Detail Information is present here详细信息在这里

There are a few options:有几个选项:

  1. Enter the container if it is running using: docker exec -it container_id bash and then edit the file, then use docker commit to save the changes.如果容器正在运行,请使用以下命令输入容器: docker exec -it container_id bash 然后编辑文件,然后使用 docker commit 保存更改。
  2. You can add the name in the Dockerfile: CMD cat name >>/etc/resolve.conf可以在Dockerfile中添加名称:CMD cat name >>/etc/resolve.conf
  3. Mount the resolv.conf from your system to the image.将系统中的 resolv.conf 挂载到映像。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 chown: /etc/resolv.conf: 只读文件系统 - chown: /etc/resolv.conf: Read-only file system Docker 如何使用 /etc/resolv.conf 中定义的名称服务器启动容器 - Docker how to start container with defined nameservers in /etc/resolv.conf 如何在docker文件或脚本中以非root用户身份修改/etc/resolv.conf - how to modify /etc/resolv.conf as non root user in docker file or as script 如何从 docker-compose 文件覆盖 /etc/resolv.conf 中 Docker 的嵌入式 DNS 服务器 - How to override embedded DNS server for Docker in /etc/resolv.conf from a docker-compose file 如何更改现有 docker 容器的 resolv.conf - How to change resolv.conf for existing docker containers 当我尝试在 ubuntu:18.04 中移动 /etc/resolv.conf 时出现“设备或资源繁忙”。 怎么修? - "Device or resource busy" when i try move /etc/resolv.conf in ubuntu:18.04. How fix it? 无法在docker容器中编辑/etc/resolv.conf - unable to edit /etc/resolv.conf in docker container 如何触发容器中resolv.conf的重新加载? - How can I trigger a reload of resolv.conf in my containers? 在 Ubuntu 16.04 docker 映像中安装 apt-get:'/etc/resolv.conf':设备或资源繁忙 - apt-get install in Ubuntu 16.04 docker image: '/etc/resolv.conf': Device or resource busy AWS ECS代理在启动时找不到/etc/resolv.conf,也无法将实例添加到ECS集群 - AWS ECS agent cannot find /etc/resolv.conf when launching and cannot add instances to an ECS cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM