{"id":483701,"date":"2022-08-12T09:02:56","date_gmt":"2022-08-12T06:02:56","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/"},"modified":"2022-08-12T09:02:56","modified_gmt":"2022-08-12T06:02:56","slug":"how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/","title":{"rendered":"#How to Troubleshoot \u201cCannot Connect to the Docker Daemon\u201d Errors"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a25da5a288db\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a25da5a288db\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#%E2%80%9CHow_to_Troubleshoot_%E2%80%9CCannot_Connect_to_the_Docker_Daemon%E2%80%9D_Errors%E2%80%9D\" >&#8220;How to Troubleshoot \u201cCannot Connect to the Docker Daemon\u201d Errors&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#Problem_Symptoms\" >Problem Symptoms<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#1_Check_the_Docker_Daemon_Service_Is_Running\" >1. Check the Docker Daemon Service Is Running<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#2_Start_the_Daemon_Manually\" >2. Start the Daemon Manually<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#3_Checking_the_CLI_Is_Targeting_the_Correct_Daemon\" >3. Checking the CLI Is Targeting the Correct Daemon<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#4_Permissions_Issues\" >4. Permissions Issues<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/#Summary\" >Summary<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CHow_to_Troubleshoot_%E2%80%9CCannot_Connect_to_the_Docker_Daemon%E2%80%9D_Errors%E2%80%9D\"><\/span>&#8220;How to Troubleshoot \u201cCannot Connect to the Docker Daemon\u201d Errors&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<!-- UNCACHED CONTENT --><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-805981\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/Docker-New.jpeg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Graphic showing the Docker logo\" width=\"1600\" height=\"900\"\/><\/p>\n<p>Docker is one of the leading platforms for building and running software containers. It comes with everything you need to use containers on either a single host or multiple distributed nodes in Swarm mode.<\/p>\n<p>Docker has a daemon-based architecture. The software that\u2019s responsible for creating and starting containers is independent of the CLI process that accepts your commands. This means you\u2019ll see errors in the CLI if you try to run commands without an active daemon connection. In this article, we\u2019ll share some methods for troubleshooting these frustrating messages.<\/p>\n<h2 id=\"problem-symptoms\"><span class=\"ez-toc-section\" id=\"Problem_Symptoms\"><\/span>Problem Symptoms<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Docker CLI is reliant on a daemon connection being available. It interacts with the daemon using API calls. When the configured daemon\u2019s inaccessible, <code>docker<\/code> commands like <code>docker ps<\/code>, <code>docker run<\/code>, and <code>docker build<\/code> will show an error message similar to this one:<\/p>\n<pre>$ docker run hello-world:latest&#13;\nCannot connect to the Docker daemon at unix:\/\/\/var\/run\/docker.sock&#13;\nIs the docker daemon running?<\/pre>\n<p>This reveals that the CLI tried to communicate with the Docker daemon using the <code>\/var\/run\/docker.sock<\/code> Unix socket. The socket\u2019s not open so the connection failed.<\/p>\n<h2 id=\"check-the-docker-daemon-service-is-running\"><span class=\"ez-toc-section\" id=\"1_Check_the_Docker_Daemon_Service_Is_Running\"><\/span>1. Check the Docker Daemon Service Is Running<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Docker daemon is usually managed by a systemd service that automatically starts Docker after your host reboots. You can begin troubleshooting by checking whether this service is running:<\/p>\n<pre>$ sudo systemctl status docker&#13;\ndocker.service - Docker <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">App<\/a>lication Container Engine&#13;\n     Loaded: loaded (\/lib\/systemd\/system\/docker.service; enabled; vendor preset: enabled)&#13;\n     Active: inactive (dead)<\/pre>\n<p>The service should report <code>Active: active (running)<\/code> if the daemon is running. The example above shows <code>inactive (dead)<\/code> which means the daemon has stopped.<\/p>\n<p>Start Docker using the following command:<\/p>\n<pre>$ sudo systemctl start docker<\/pre>\n<p>Now you should be able to run <code>docker<\/code> CLI commands successfully.<\/p>\n<p>You might find that Docker stays in the stopped state after you reboot your machine. You can solve this by enabling the service, allowing systemd to start it automatically:<\/p>\n<pre>$ sudo systemctl enable docker&#13;\n$ sudo systemctl daemon-reload<\/pre>\n<p>The <code>daemon-reload<\/code> command instructs systemd to reload its configuration to apply the change.<\/p>\n<h2 id=\"start-the-daemon-manually\"><span class=\"ez-toc-section\" id=\"2_Start_the_Daemon_Manually\"><\/span>2. Start the Daemon Manually<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You might sometimes use a system that doesn\u2019t have the Docker service installed. You can manually start the Docker daemon using the <code>dockerd<\/code> command. This usually needs to be run as <code>root<\/code>.<\/p>\n<pre>$ sudo dockerd&#13;\nINFO[2022-06-29T15:12:49.303428726+01:00] Starting up<\/pre>\n<p>Docker will remain accessible for as long as the command\u2019s running. Use Ctrl+C to stop the daemon.<\/p>\n<h2 id=\"checking-the-cli-is-targeting-the-correct-daemon\"><span class=\"ez-toc-section\" id=\"3_Checking_the_CLI_Is_Targeting_the_Correct_Daemon\"><\/span>3. Checking the CLI Is Targeting the Correct Daemon<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Problems can occur when the CLI is trying to connect to a remote Docker daemon instance. This is usually the cause when the error message shows a TCP address:<\/p>\n<pre>$ docker run hello-world:latest&#13;\nCannot connect to the Docker daemon at tcp:\/\/\/0.0.0.0:2375<\/pre>\n<p>In this example, the <code>docker<\/code> CLI is trying to contact the Docker daemon at <code>0.0.0.0:2375<\/code> using TCP, instead of the local Unix Docker socket. This will fail if the Docker daemon\u2019s TCP support is disabled or the specified host is inaccessible on the network.<\/p>\n<p>You can usually resolve this by switching to the correct Docker CLI context for the daemon connection you want to use:<\/p>\n<pre>$ docker context use default<\/pre>\n<p>You can list all the available contexts and the daemon endpoints they connect to with the <code>context ls<\/code> command:<\/p>\n<pre>$ docker context ls&#13;\nNAME        DESCRIPTION                               DOCKER ENDPOINT             &#13;\ndefault *   Current DOCKER_HOST based configuration   unix:\/\/\/var\/run\/docker.sock<\/pre>\n<p>The currently selected context is highlighted with an asterisk.<\/p>\n<p>Unexpected values in the <code>DOCKER ENDPOINT<\/code> column are usually caused by the <code>DOCKER_HOST<\/code> environment variable being set. You\u2019ll see a warning when this is the case:<\/p>\n<pre>$ export DOCKER_HOST=1.2.3.4&#13;\n$ docker context ls&#13;\nNAME        DESCRIPTION                               DOCKER ENDPOINT&#13;\ndefault *   Current DOCKER_HOST based configuration   tcp:\/\/1.2.3.4:2375&#13;\nWarning: DOCKER_HOST environment variable overrides the active context. To use a context, either set the global --context flag, or unset DOCKER_HOST environment variable.<\/pre>\n<p>The presence of the <code>DOCKER_HOST<\/code> environment variable in your shell overrides the endpoint defined by your selected context. In this example, <code>docker<\/code> commands will always target the daemon instance at <code>tcp:\/\/1.2.3.4:2375<\/code>.<\/p>\n<p>This problem can be resolved by clearing the <code>DOCKER_HOST<\/code> variable:<\/p>\n<pre>$ export DOCKER_HOST=<\/pre>\n<p>Docker will now use the endpoint configured by your active context. This will be the default local Unix socket at <code>\/var\/run\/docker.sock<\/code> unless you\u2019ve manually set up a custom context.<\/p>\n<pre>$ docker context ls&#13;\nNAME        DESCRIPTION                               DOCKER ENDPOINT             &#13;\ndefault *   Current DOCKER_HOST based configuration   unix:\/\/\/var\/run\/docker.sock<\/pre>\n<h2 id=\"permissions-issues\"><span class=\"ez-toc-section\" id=\"4_Permissions_Issues\"><\/span>4. Permissions Issues<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Incorrect user permissions on Docker\u2019s socket are another common cause of daemon connection issues. This kind of problem usually shows a slightly different error message:<\/p>\n<pre>$ docker run hello-world:latest&#13;\nGot permission denied while trying to connect to the Docker daemon socket at unix:\/\/\/var\/run\/docker.sock<\/pre>\n<p>This happens when your Unix user account lacks permission to interact with the socket that exposes the Docker API. Adding yourself to the <code>docker<\/code> group is the best practice way to resolve this problem:<\/p>\n<pre>$ sudo usermod -aG docker $USER<\/pre>\n<p>You\u2019ll need to open a new shell window or logout and back in again for this change to take effect. You should now be able to run <code>docker<\/code> commands without running into permissions problems.<\/p>\n<h2 id=\"summary\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u201cCannot connect to the Docker daemon\u201d appears when the Docker CLI is unable to communicate with a Docker daemon instance using your current configuration. This is often because the Docker daemon service has been stopped or disabled. You could also be trying to connect to a remote Docker host that\u2019s gone offline.<\/p>\n<p>You should now be aware of the possible causes of this problem and the common ways to solve it. Troubleshoot the error by checking your Docker daemon settings, restarting the Docker service, and making sure your user account has permission to interact with Docker\u2019s socket.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/devops\/how-to-troubleshoot-cannot-connect-to-the-docker-daemon-errors\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;How to Troubleshoot \u201cCannot Connect to the Docker Daemon\u201d Errors&#8221; Docker is one of the leading platforms for building and running software containers. It comes with everything you need to use containers on either a single host or multiple distributed nodes in Swarm mode. Docker has a daemon-based architecture. The software that\u2019s responsible for creating&#8230;<\/p>\n","protected":false},"author":1,"featured_media":483702,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/05\/Docker-New.jpeg?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-483701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/483701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=483701"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/483701\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/483702"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=483701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=483701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=483701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}