Docker overrides my /etc/resolv.conf file inside containers - Unix & Linux Stack Exchange (https://cdn.sstatic.net/Sites/unix/Img/apple-touch-icon.png?v=5cf7fe716a89) (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/opensearch.xml) (https://unix.stackexchange.com/questions/347939/docker-overrides-my-etc-resolv-conf-file-inside-containers) (Feed for question 'Docker overrides my /etc/resolv.conf file inside containers') (https://unix.stackexchange.com/feeds/question/347939) (site logo) By clicking “Sign up”, you agree to our (https://unix.stackexchange.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://unix.stackexchange.com/legal/privacy-policy) privacy policy . Sign up with Google OR Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (https://unix.stackexchange.com/users/login) Log in Skip to main content (Search on Unix & Linux…) (https://unix.stackexchange.com/help) (Help Center and other resources) (https://stackexchange.com/) (A list of all 183 Stack Exchange sites) (Click to show search) (https://unix.stackexchange.com/users/login?ssrc=head&returnurl=https%3a%2f%2funix.stackexchange.com%2fquestions%2f347939%2fdocker-overrides-my-etc-resolv-conf-file-inside-containers) Log in (https://unix.stackexchange.com/users/signup?ssrc=head&returnurl=https%3a%2f%2funix.stackexchange.com%2fquestions%2f347939%2fdocker-overrides-my-etc-resolv-conf-file-inside-containers) Sign up (https://unix.stackexchange.com/) (Unix & Linux) (https://unix.stackexchange.com/) Home (https://unix.stackexchange.com/questions) Questions (https://unix.stackexchange.com/unanswered) Unanswered (https://stackoverflow.ai/) AI Assist Labs (https://unix.stackexchange.com/tags) Tags (https://chat.stackexchange.com/rooms/158962/stack-exchange-lobby) Chat (https://unix.stackexchange.com/users) Users (https://stackoverflow.com/jobs/companies?so_medium=unix&so_source=SiteNav) Companies Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=unix-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams (Illustration of upvote icon after it is clicked) Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. Upvoting indicates when questions and answers are useful. (https://stackoverflow.com/help/whats-reputation) What's reputation and how do I get it? Instead, you can save this post to reference later. Save this post for later Not now (Illustration of upvote icon after it is clicked) Thanks for your vote! You now have 5 free votes weekly. Free votescount toward the total vote score does not give reputation to the author Continue to help good content that is interesting, well-researched, and useful, rise to the top! To gain full voting privileges, (https://unix.stackexchange.com/help/whats-reputation) earn reputation . Got it! Go to help center to learn more (https://cdn.sstatic.net/Sites/unix/Img/apple-touch-icon.png?v=5cf7fe716a89) (https://unix.stackexchange.com/questions/347939/docker-overrides-my-etc-resolv-conf-file-inside-containers) Docker overrides my /etc/resolv.conf file inside containers (https://unix.stackexchange.com/questions/ask) Ask Question (2017-02-27 17:19:38Z) Asked 8 years, 7 months ago Modified (https://unix.stackexchange.com/questions/347939/docker-overrides-my-etc-resolv-conf-file-inside-containers?lastactivity) (2020-01-12 11:22:53Z) 5 years, 9 months ago (Viewed 55,576 times) Viewed 56k times This question shows research effort; it is useful and clear 31 (This question does not show any research effort; it is unclear or not useful) Save this question. (https://unix.stackexchange.com/posts/347939/timeline) Show activity on this post. I want to set my resin/rpi-raspbian:jessie container's /etc/resolv.conf to: nameserver 208.67.222.222 nameserver 208.67.220.220 My Dockerfile has the following line: ADD resolv.conf /etc/resolv.conf This added file contains the correct nameservers. My Docker host's /etc/resolv.conf contains the correct information. I'm running the container like this: docker run -itd --cap-add=NET_ADMIN --device /dev/net/tun \ -v /home/pi/share/ovpn:/ovpn \ --privileged --network=internet_disabled --name vpn-client \ --dns=208.67.222.222 \ openvpn-client_nat-gateway /bin/bash Despite all of this, the container gives this output: root@642b0f4716ba:/# cat /etc/resolv.conf nameserver 127.0.0.11 options ndots:0 It's only after I change the resolv.conf manually from within the container (or with docker exec) that it looks right. I'd rather avoid having to fix it with an exec command. Anybody have an idea what's going on here? (https://unix.stackexchange.com/questions/tagged/docker) (show questions tagged 'docker') docker (https://unix.stackexchange.com/q/347939) (Short permalink to this question) Share (https://unix.stackexchange.com/posts/347939/edit) Improve this question Follow Follow this question to receive notifications (https://unix.stackexchange.com/posts/347939/revisions) (show all edits to this post) edited (2020-01-12 11:22:53Z) Jan 12, 2020 at 11:22 (https://unix.stackexchange.com/users/116858/kusalananda) (Kusalananda's user avatar) (https://unix.stackexchange.com/users/116858/kusalananda) Kusalananda (Moderator) ♦ (reputation score 355,501) 356k (42 gold badges) 42 42 gold badges (735 silver badges) 735 735 silver badges (1.1k bronze badges) 1.1k 1.1k bronze badges asked (2017-02-27 17:19:38Z) Feb 27, 2017 at 17:19 (https://unix.stackexchange.com/users/159946/duncan-marshall) (Duncan Marshall's user avatar) (https://unix.stackexchange.com/users/159946/duncan-marshall) Duncan Marshall Duncan Marshall (reputation score) 651 (1 gold badge) 1 1 gold badge (7 silver badges) 7 7 silver badges (18 bronze badges) 18 18 bronze badges 2 There are a few cases described on (https://wiki.debian.org/NetworkConfiguration#Defining_the_.28DNS.29_Nameservers) their wiki which could explain your situation. Julie Pelletier – (https://unix.stackexchange.com/users/167583/julie-pelletier) (7,659 reputation) Julie Pelletier 2017-02-28 00:08:17 +00:00 Commented (2017-02-28 00:08:17Z, License: CC BY-SA 3.0) Feb 28, 2017 at 0:08 Take a look at (https://stackoverflow.com/questions/45672193/curl-command-returns-nothing-in-dockerfile-whilst-it-works-in-every-other-linu) my question and the answer. Zeinab Abbasimazar – (https://unix.stackexchange.com/users/61120/zeinab-abbasimazar) (303 reputation) Zeinab Abbasimazar 2017-08-15 08:11:48 +00:00 Commented (2017-08-15 08:11:48Z, License: CC BY-SA 3.0) Aug 15, 2017 at 8:11 (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 3 Answers 3 Sorted by: (https://unix.stackexchange.com/questions/347939/docker-overrides-my-etc-resolv-conf-file-inside-containers?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful 24 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://unix.stackexchange.com/posts/348406/timeline) Show activity on this post. AFAIK, docker overrides some files in an image when it's started , even if they were ADDed in Dockerfile. This for sure includes /etc/hosts , and most probably the same happens for /etc/resolv.conf too. This is apparently used to properly build the default "internal" network of Docker (so that images see each other, but not host, etc.) If you are really sure you want to override/modify some of those files, I believe you must do that as part of the runtime actions, that is as part of the CMD line. For example: ... ADD resolv.conf /etc/resolv.conf.override CMD cp /etc/resolv.conf.override /etc/resolv.conf && \ your_old_commands... (https://unix.stackexchange.com/a/348406) (Short permalink to this answer) Share (https://unix.stackexchange.com/posts/348406/edit) Improve this answer Follow Follow this answer to receive notifications answered (2017-03-01 14:45:31Z) Mar 1, 2017 at 14:45 (https://unix.stackexchange.com/users/11352/akavel) (akavel's user avatar) (https://unix.stackexchange.com/users/11352/akavel) akavel akavel (reputation score) 456 (5 silver badges) 5 5 silver badges (9 bronze badges) 9 9 bronze badges 1 (number of 'useful comment' votes received) 6 This is correct. /etc/resolv.conf is copied from the host when a container is started. wisbucky – (https://unix.stackexchange.com/users/54444/wisbucky) (3,708 reputation) wisbucky 2018-06-27 21:40:06 +00:00 Commented (2018-06-27 21:40:06Z, License: CC BY-SA 4.0) Jun 27, 2018 at 21:40 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful 7 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://unix.stackexchange.com/posts/349743/timeline) Show activity on this post. As I can see you are using user-defined networks and Docker Engine version >= 1.10. So from the official docker engine documentation about Embedded DNS server in user-defined networks : These --dns IP addresses are managed by the embedded DNS server and will not be updated in the container's /etc/resolv.conf file. Your dns has to work, but you will not see in any configuration file. (https://docs.docker.com/engine/userguide/networking/configure-dns/) References . (https://unix.stackexchange.com/a/349743) (Short permalink to this answer) Share (https://unix.stackexchange.com/posts/349743/edit) Improve this answer Follow Follow this answer to receive notifications (https://unix.stackexchange.com/posts/349743/revisions) (show all edits to this post) edited (2017-03-07 15:04:45Z) Mar 7, 2017 at 15:04 (https://unix.stackexchange.com/users/153195/gad3r) (GAD3R's user avatar) (https://unix.stackexchange.com/users/153195/gad3r) GAD3R (reputation score 69,775) 69.8k (32 gold badges) 32 32 gold badges (147 silver badges) 147 147 silver badges (216 bronze badges) 216 216 bronze badges answered (2017-03-07 14:38:12Z) Mar 7, 2017 at 14:38 (https://unix.stackexchange.com/users/140947/thiago-almeida) (Thiago Almeida's user avatar) (https://unix.stackexchange.com/users/140947/thiago-almeida) Thiago Almeida Thiago Almeida (reputation score) 181 (5 bronze badges) 5 5 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful 1 (This answer is not useful) Save this answer. (Loading when this answer was accepted…) (https://unix.stackexchange.com/posts/466000/timeline) Show activity on this post. I have solved the issue if it is the web app for containers in Azure. There are 2 containers mate . Kudu and the host Steps 1.Install the ssh from your docker file ( also include a sshd config ) 2.create a containerstart.sh ( which updates the resolv.conf) 3.Set the entry point inside there Now the host resolv.conf gets updated and you can use any dns you desire PS: If you can't pick up the custom DNS in the network do not worry. We could not either. Might need to resetup if you are using an ASE environment (https://unix.stackexchange.com/a/466000) (Short permalink to this answer) Share (https://unix.stackexchange.com/posts/466000/edit) Improve this answer Follow Follow this answer to receive notifications answered (2018-08-31 10:45:13Z) Aug 31, 2018 at 10:45 (https://unix.stackexchange.com/users/245703/r%c4%b1fat-erdem-sahin) (Rıfat Erdem Sahin's user avatar) (https://unix.stackexchange.com/users/245703/r%c4%b1fat-erdem-sahin) Rıfat Erdem Sahin Rıfat Erdem Sahin (reputation score) 111 (3 bronze badges) 3 3 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) You must (https://unix.stackexchange.com/users/login?ssrc=question_page&returnurl=https%3a%2f%2funix.stackexchange.com%2fquestions%2f347939) log in to answer this question. Start asking to get answers Find the answer to your question by asking. (https://unix.stackexchange.com/questions/ask) Ask question Explore related questions (https://unix.stackexchange.com/questions/tagged/docker) (show questions tagged 'docker') docker See similar questions with these tags. The Overflow Blog (https://stackoverflow.blog/2025/10/07/context-is-king-for-secure-ai-generated-code/?cb=1) Context is king for secure, AI-generated code (https://stackoverflow.blog/2025/10/08/a-new-look-for-comments/?cb=1) A new look for comments Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/412987/please-welcome-v2blast-back-to-the-community-team?cb=1) Please welcome V2Blast back to the Community Team! (Meta Stack Exchange) (https://meta.stackexchange.com/questions/412992/a-first-look-stack-overflow-redesign?cb=1) A First Look: Stack Overflow Redesign Related (https://unix.stackexchange.com/questions/122279/linking-docker-containers?rq=1) (Question score (upvotes - downvotes)) 4 (https://unix.stackexchange.com/questions/122279/linking-docker-containers?rq=1) Linking Docker containers (https://unix.stackexchange.com/questions/123482/application-updates-inside-of-docker-containers?rq=1) (Question score (upvotes - downvotes)) 9 (https://unix.stackexchange.com/questions/123482/application-updates-inside-of-docker-containers?rq=1) Application updates inside of Docker containers? (https://unix.stackexchange.com/questions/404499/what-is-the-difference-between-etc-group-and-etc-subgid?rq=1) (Question score (upvotes - downvotes)) 4 (https://unix.stackexchange.com/questions/404499/what-is-the-difference-between-etc-group-and-etc-subgid?rq=1) What is the difference between /etc/group and /etc/subgid? (https://unix.stackexchange.com/questions/579532/connect-2-docker-containers-through-docker-compose?rq=1) (Question score (upvotes - downvotes)) 1 (https://unix.stackexchange.com/questions/579532/connect-2-docker-containers-through-docker-compose?rq=1) Connect 2 docker-containers through docker-compose (https://unix.stackexchange.com/questions/647996/docker-container-dns-not-working-with-pihole?rq=1) (Question score (upvotes - downvotes)) 12 (https://unix.stackexchange.com/questions/647996/docker-container-dns-not-working-with-pihole?rq=1) Docker container DNS not working with pihole (https://unix.stackexchange.com/questions/688275/run-1024-docker-containers?rq=1) (Question score (upvotes - downvotes)) 1 (https://unix.stackexchange.com/questions/688275/run-1024-docker-containers?rq=1) Run > 1024 docker containers (https://unix.stackexchange.com/questions/716702/identify-the-var-lib-docker-containers-id-docker-directory?rq=1) (Question score (upvotes - downvotes)) 0 (https://unix.stackexchange.com/questions/716702/identify-the-var-lib-docker-containers-id-docker-directory?rq=1) Identify the /var/lib/docker/containers/$ID/ docker directory (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Role-playing Games Stack Exchange) (https://rpg.stackexchange.com/questions/216753/how-do-i-as-a-player-create-a-gate-that-requires-a-token-to-use) How do I, as a player, create a gate that requires a token to use? (Movies & TV Stack Exchange) (https://movies.stackexchange.com/questions/128550/old-b-w-about-masquerade-masks-then-faces-change-into-them) Old B/W about masquerade masks, then faces change into them (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/299518/when-was-dr-who-shown-on-dr-who) When was Dr Who shown on Dr Who? (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/32135/ms-dos-vector-fractal-generator) MS-DOS vector fractal generator? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/133508/a-pranaytious-minesweeper) A Pranaytious Minesweeper (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/756624/tvs-only-bidirectional-or-can-also-use-unidirectional) TVS, only bidirectional or can also use unidirectional? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/133511/yet-another-machine-giving-o-or-x-for-sequences-of-positive-numbers) yet another machine giving O or X for sequences of positive numbers (Science Fiction & Fantasy Stack Exchange) (https://scifi.stackexchange.com/questions/299541/highlander-episode-villain-of-the-week-was-a-ww1-officer) Highlander episode- villain of the Week was a WW1 officer (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/756608/using-lm1084-ldo-without-capacitors-can-that-cause-stability-and-heat-dissipati) Using LM1084 LDO without capacitors. Can that cause stability and heat dissipation design flaws in my 22V voltage limiter for a solar panel? (Puzzling Stack Exchange) (https://puzzling.stackexchange.com/questions/133495/consecutive-letters) Consecutive Letters (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/800232/how-to-clearly-indicate-a-device-is-not-mounted) How to clearly indicate a device is not mounted (MathOverflow) (https://mathoverflow.net/questions/501289/history-of-the-definition-of-charts-and-atlases-for-manifolds) History of the definition of charts and atlases for manifolds (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5100409/taylor-series-of-a-finite-degree-polynomial) Taylor Series of a finite degree polynomial (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5100301/is-the-number-system-for-x-assumed-beforehand-when-proving-the-quadratic-formula) Is the number system for x assumed beforehand when proving the quadratic formula? (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/756583/how-can-i-measure-power-supply-noise-and-ripple-lower-than-100%c2%b5v) How can I measure power supply noise and ripple lower than 100µV? (Philosophy Stack Exchange) (https://philosophy.stackexchange.com/questions/131020/what-are-the-epistemological-differences-between-scientific-and-religious-approa) What are the epistemological differences between scientific and religious approaches to knowledge? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/221637/refereeing-a-paper-where-one-of-authors-became-my-co-author) Refereeing a paper where one of authors became my co-author (Biblical Hermeneutics Stack Exchange) (https://hermeneutics.stackexchange.com/questions/108690/are-the-our-father-mentioned-in-matthew-69-and-isaiah-6316-one-and-the-same) Are the "our Father" mentioned in Matthew 6:9 and Isaiah 63:16 one and the same? (Mathematica Stack Exchange) (https://mathematica.stackexchange.com/questions/315615/why-graph-and-edgeshapefunction-do-not-respect-order-of-vertices-of-edges) Why Graph and EdgeShapeFunction do not respect order of vertices of edges? (Stack Overflow) (https://stackoverflow.com/questions/79784113/how-to-correctly-pass-a-filename-with-a-single-quote-to-ffmpegs-subtitles-filte) How to correctly pass a filename with a single quote to ffmpeg's subtitles filter in Python? (Unix & Linux Stack Exchange) (https://unix.stackexchange.com/questions/800287/how-can-i-find-common-prefixes-in-file-names-to-group-them) How can I find common prefixes in file names to group them? (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/752168/adding-a-colormap-to-a-solution-curve-of-a-vector-field) Adding a colormap to a solution curve of a vector field (Hinduism Stack Exchange) (https://hinduism.stackexchange.com/questions/65627/the-true-purpose-in-life-according-to-hinduism) The true purpose in life according to Hinduism? (Super User) (https://superuser.com/questions/1926254/what-is-a-git-command-to-remove-all-files-from-cloned-repository-but-still-be-ab) What is a git command to remove all files from cloned repository but still be able to pull? (https://unix.stackexchange.com/feeds/question/347939) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://unix.stackexchange.com/feeds/question/347939) () Why are you flagging this comment? (20) It contains harassment, bigotry or abuse. This comment attacks a person or group. Learn more in our (https://unix.stackexchange.com/conduct/abusive-behavior) Code of Conduct . (40) It's unfriendly or unkind. This comment is rude or condescending. Learn more in our (https://unix.stackexchange.com/conduct/abusive-behavior) Code of Conduct . (39) Not needed. This comment is not relevant to the post. (19) Something else. A problem not listed above. Try to be as specific as possible. Flag comment Cancel You have 0 flags left today (GPP Locator) (https://unix.stackexchange.com/) Unix & Linux (https://unix.stackexchange.com/tour) Tour (https://unix.stackexchange.com/help) Help (https://chat.stackexchange.com/?tab=all&sort=active) Chat (https://unix.stackexchange.com/contact) Contact (https://unix.meta.stackexchange.com/) Feedback (https://stackoverflow.co/) Company (https://stackoverflow.com/) Stack Overflow (https://stackoverflow.co/teams/) Teams (https://stackoverflow.co/advertising/) Advertising (https://stackoverflow.co/advertising/employer-branding/) Talent (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service Your Privacy Choices (https://policies.stackoverflow.co/stack-overflow/cookie-policy) Cookie Policy (https://stackexchange.com/) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog/?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.10.6.34876 Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group. This site is not affiliated with Linus Torvalds or The Open Group in any way. By continuing to use this website, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our (https://policies.stackoverflow.co/stack-overflow/cookie-policy/) Cookie Policy . By exiting this window, default cookies will be accepted. To reject cookies, select an option from below. Necessary cookies only Customize settings