简体   繁体   中英

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

I have a docker image I deployed onto OpenShift (using oc new-app). However, it's not working properly because of a missing dns search entry in /etc/resolv.conf. When I create a container from my docker image and run it, I can specify the parmater --dns-search.

How can I do something similar during the deployment of my image onto OpenShift with oc new-app?

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. Then restart the service

# systemctl restart atomic-openshift-node.service

The DNS ip will be prepended in all /etc/resolv.conf file of Pods.

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.
  2. You can add the name in the Dockerfile: CMD cat name >>/etc/resolve.conf
  3. Mount the resolv.conf from your system to the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM