{"id":820,"date":"2021-11-15T13:01:08","date_gmt":"2021-11-15T13:01:08","guid":{"rendered":"https:\/\/mklasen.com\/?p=820"},"modified":"2021-11-15T13:01:09","modified_gmt":"2021-11-15T13:01:09","slug":"docker-fails-to-connect-with-archive-ubuntu-com","status":"publish","type":"post","link":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/","title":{"rendered":"Docker fails to connect with archive.ubuntu.com"},"content":{"rendered":"\n

Upon launching a new docker-compose setup, my Dockerfile suddenly had issues installing some packages, showing errors like:<\/p>\n\n\n\n

Temporary failure resolving 'archive.ubuntu.com'<\/code><\/pre>\n\n\n\n

It took me some time to figure out what was happening, but this Medium post<\/a> got me in the right direction. Somehow, when building, docker fails to run DNS queries.<\/p>\n\n\n\n

Debugging: what causes this?<\/strong><\/p>\n\n\n\n

We can test the default setup by running the following command:<\/p>\n\n\n\n

docker run busybox nslookup google.com<\/code><\/p>\n\n\n\n

This should output something like:<\/p>\n\n\n\n

connection timed out; no servers could be reached<\/code><\/pre>\n\n\n\n

Meaning that docker is unable to resolve domain names.<\/p>\n\n\n\n

Set a different DNS server<\/strong><\/p>\n\n\n\n

Let’s specify a different DNS server in that command:<\/p>\n\n\n\n

docker run --dns 192.168.1.1 busybox nslookup google.com<\/code><\/pre>\n\n\n\n

Updating the global docker configuration<\/strong><\/p>\n\n\n\n

When you’ve found a server that works, let’s add it to the global configuration.<\/p>\n\n\n\n

Edit or create the daemon.json file:<\/p>\n\n\n\n

sudo nano \/etc\/docker\/daemon.json<\/code><\/pre>\n\n\n\n

My file looks like this:<\/p>\n\n\n\n

{\n    \"dns\": [\"192.168.1.1\"]\n}<\/code><\/pre>\n\n\n\n

Then we just need to restart the docker daemon:<\/p>\n\n\n\n

sudo service docker restart<\/code><\/pre>\n\n\n\n

And we’re good to go!<\/p>\n\n\n\n

<\/p>\n\n\n\n

Happy developing!<\/strong><\/p>\n\n\n\n

<\/p>\n\n\n\n

Full error log<\/strong><\/p>\n\n\n\n

Step 2\/9 : RUN apt-get update && apt-get -y install cron httrack curl\n ---> Running in 9cd52019953d\nErr:1 http:\/\/archive.ubuntu.com\/ubuntu focal InRelease\n  Temporary failure resolving 'archive.ubuntu.com'\nErr:2 http:\/\/security.ubuntu.com\/ubuntu focal-security InRelease\n  Temporary failure resolving 'security.ubuntu.com'\nErr:3 http:\/\/archive.ubuntu.com\/ubuntu focal-updates InRelease\n  Temporary failure resolving 'archive.ubuntu.com'\nErr:4 http:\/\/archive.ubuntu.com\/ubuntu focal-backports InRelease\n  Temporary failure resolving 'archive.ubuntu.com'\nReading package lists...\nW: Failed to fetch http:\/\/archive.ubuntu.com\/ubuntu\/dists\/focal\/InRelease  Temporary failure resolving 'archive.ubuntu.com'\nW: Failed to fetch http:\/\/archive.ubuntu.com\/ubuntu\/dists\/focal-updates\/InRelease  Temporary failure resolving 'archive.ubuntu.com'\nW: Failed to fetch http:\/\/archive.ubuntu.com\/ubuntu\/dists\/focal-backports\/InRelease  Temporary failure resolving 'archive.ubuntu.com'\nW: Failed to fetch http:\/\/security.ubuntu.com\/ubuntu\/dists\/focal-security\/InRelease  Temporary failure resolving 'security.ubuntu.com'\nW: Some index files failed to download. They have been ignored, or old ones used instead.\nReading package lists...\nBuilding dependency tree...\nReading state information...\nE: Unable to locate package cron\nE: Unable to locate package httrack\nE: Unable to locate package curl<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

Upon launching a new docker-compose setup, my Dockerfile suddenly had issues installing some packages, showing errors like: It took me some time to figure out what was happening, but this Medium post got me in the right direction. Somehow, when building, docker fails to run DNS queries. Debugging: what causes this? We can test the […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\nDocker fails to connect with archive.ubuntu.com - Marinus Klasen<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker fails to connect with archive.ubuntu.com - Marinus Klasen\" \/>\n<meta property=\"og:description\" content=\"Upon launching a new docker-compose setup, my Dockerfile suddenly had issues installing some packages, showing errors like: It took me some time to figure out what was happening, but this Medium post got me in the right direction. Somehow, when building, docker fails to run DNS queries. Debugging: what causes this? We can test the […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\" \/>\n<meta property=\"og:site_name\" content=\"Marinus Klasen\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:author\" content=\"http:\/\/facebook.com\/marinus.klasen\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-15T13:01:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-15T13:01:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Marinus Klasen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/marinusklasen\" \/>\n<meta name=\"twitter:site\" content=\"@marinusklasen\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Marinus Klasen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\"},\"author\":{\"name\":\"Marinus Klasen\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"headline\":\"Docker fails to connect with archive.ubuntu.com\",\"datePublished\":\"2021-11-15T13:01:08+00:00\",\"dateModified\":\"2021-11-15T13:01:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\"},\"wordCount\":152,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"articleSection\":[\"General\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\",\"url\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\",\"name\":\"Docker fails to connect with archive.ubuntu.com - Marinus Klasen\",\"isPartOf\":{\"@id\":\"https:\/\/mklasen.com\/#website\"},\"datePublished\":\"2021-11-15T13:01:08+00:00\",\"dateModified\":\"2021-11-15T13:01:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mklasen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General\",\"item\":\"https:\/\/mklasen.com\/general\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker fails to connect with archive.ubuntu.com\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mklasen.com\/#website\",\"url\":\"https:\/\/mklasen.com\/\",\"name\":\"Marinus Klasen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mklasen.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"nl-NL\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29\",\"name\":\"Marinus Klasen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"contentUrl\":\"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg\",\"width\":1500,\"height\":1000,\"caption\":\"Marinus Klasen\"},\"logo\":{\"@id\":\"https:\/\/mklasen.com\/#\/schema\/person\/image\/\"},\"description\":\"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter\",\"sameAs\":[\"http:\/\/facebook.com\/marinus.klasen\",\"https:\/\/nl.linkedin.com\/in\/marinusklasen\",\"https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker fails to connect with archive.ubuntu.com - Marinus Klasen","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/","og_locale":"nl_NL","og_type":"article","og_title":"Docker fails to connect with archive.ubuntu.com - Marinus Klasen","og_description":"Upon launching a new docker-compose setup, my Dockerfile suddenly had issues installing some packages, showing errors like: It took me some time to figure out what was happening, but this Medium post got me in the right direction. Somehow, when building, docker fails to run DNS queries. Debugging: what causes this? We can test the […]","og_url":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/","og_site_name":"Marinus Klasen","article_publisher":"http:\/\/facebook.com\/marinus.klasen","article_author":"http:\/\/facebook.com\/marinus.klasen","article_published_time":"2021-11-15T13:01:08+00:00","article_modified_time":"2021-11-15T13:01:09+00:00","og_image":[{"width":512,"height":512,"url":"https:\/\/mklasen.com\/content\/uploads\/2020\/03\/cropped-cropped-mklasen-logo-margin-1.png","type":"image\/png"}],"author":"Marinus Klasen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/marinusklasen","twitter_site":"@marinusklasen","twitter_misc":{"Written by":"Marinus Klasen","Est. reading time":"2 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#article","isPartOf":{"@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/"},"author":{"name":"Marinus Klasen","@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"headline":"Docker fails to connect with archive.ubuntu.com","datePublished":"2021-11-15T13:01:08+00:00","dateModified":"2021-11-15T13:01:09+00:00","mainEntityOfPage":{"@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/"},"wordCount":152,"commentCount":0,"publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"articleSection":["General"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/","url":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/","name":"Docker fails to connect with archive.ubuntu.com - Marinus Klasen","isPartOf":{"@id":"https:\/\/mklasen.com\/#website"},"datePublished":"2021-11-15T13:01:08+00:00","dateModified":"2021-11-15T13:01:09+00:00","breadcrumb":{"@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/mklasen.com\/docker-fails-to-connect-with-archive-ubuntu-com\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mklasen.com\/"},{"@type":"ListItem","position":2,"name":"General","item":"https:\/\/mklasen.com\/general\/"},{"@type":"ListItem","position":3,"name":"Docker fails to connect with archive.ubuntu.com"}]},{"@type":"WebSite","@id":"https:\/\/mklasen.com\/#website","url":"https:\/\/mklasen.com\/","name":"Marinus Klasen","description":"","publisher":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mklasen.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"nl-NL"},{"@type":["Person","Organization"],"@id":"https:\/\/mklasen.com\/#\/schema\/person\/bbad02776afb72dfba2ebfe1956a4e29","name":"Marinus Klasen","image":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/","url":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","contentUrl":"https:\/\/mklasen.com\/content\/uploads\/2021\/01\/DONE1171.jpg","width":1500,"height":1000,"caption":"Marinus Klasen"},"logo":{"@id":"https:\/\/mklasen.com\/#\/schema\/person\/image\/"},"description":"Marinus has been working in software\/web development for more than a decade. Since 2020 his attention shifted on sharing knowledge and developing products and tools for sharing knowledge. Marinus Klasen on Twitter","sameAs":["http:\/\/facebook.com\/marinus.klasen","https:\/\/nl.linkedin.com\/in\/marinusklasen","https:\/\/twitter.com\/http:\/\/twitter.com\/marinusklasen"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Marinus Klasen","author_link":"https:\/\/mklasen.com\/author\/mklasen\/"},"_links":{"self":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/820"}],"collection":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/comments?post=820"}],"version-history":[{"count":1,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/820\/revisions"}],"predecessor-version":[{"id":821,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/posts\/820\/revisions\/821"}],"wp:attachment":[{"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/media?parent=820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/categories?post=820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mklasen.com\/wp-json\/wp\/v2\/tags?post=820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}