{"id":64207,"date":"2023-05-11T19:47:41","date_gmt":"2023-05-11T19:47:41","guid":{"rendered":"https:\/\/linuxiac.com\/?p=64207"},"modified":"2023-05-11T19:47:54","modified_gmt":"2023-05-11T19:47:54","slug":"how-to-install-docker-on-raspberry-pi","status":"publish","type":"post","link":"https:\/\/linuxiac.com\/how-to-install-docker-on-raspberry-pi\/","title":{"rendered":"How to Install Docker on Raspberry Pi: A Step-by-Step Guide"},"content":{"rendered":"\n<p>Docker is a powerful tool for containerization and simplifying application deployment. At the same time, Raspberry Pi, a popular single-board computer, has become a favorite among developers for its low cost and versatility.<\/p>\n\n\n\n<p>However, installing Docker on a Raspberry Pi can be daunting for those new to the process. But don\u2019t worry \u2013 we\u2019ve got you covered!<\/p>\n\n\n\n<p>This article provides a step-by-step guide on installing Docker on a Raspberry Pi. Following these instructions, you can set up Docker and start quickly containerizing your applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-step-1-update-raspberry-pi-os\">Step 1: Update Raspberry Pi OS<\/h2>\n\n\n\n<p>Begin by updating the Raspberry Pi OS packages to recent versions. This way, we ensure we have a wholly up-to-date system. So, first, run the following two <a href=\"https:\/\/linuxiac.com\/apt-command-in-linux\/\">APT commands<\/a>:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo apt update\nsudo apt upgrade<\/code><\/span><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-update-os.jpg\"><img decoding=\"async\" width=\"934\" height=\"286\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-update-os.jpg\" alt=\"Update packages.\" class=\"wp-image-64231\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-update-os.jpg 934w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-update-os-380x116.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-update-os-768x235.jpg 768w\" sizes=\"(max-width: 934px) 100vw, 934px\" \/><\/a><figcaption class=\"wp-element-caption\">Update packages.<\/figcaption><\/figure>\n\n\n\n<p>As you can see, no updated packages are available, but if you have any, apply them before proceeding.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Docker on Raspberry Pi OS<\/h2>\n\n\n\n<p>Setting up Docker on a Raspberry Pi is simple because Docker\u2019s installation script automates the entire process. All you have to do is run the&nbsp;<a href=\"https:\/\/linuxiac.com\/curl-command-in-linux-with-exaples\/\" target=\"_blank\" rel=\"noreferrer noopener\">curl command<\/a>&nbsp;below, which will download the script and&nbsp;<a href=\"https:\/\/linuxiac.com\/how-to-use-pipes-and-named-pipes-in-linux-explained-with-examples\/\" target=\"_blank\" rel=\"noreferrer noopener\">pipe<\/a>&nbsp;it to the command line for execution.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">curl -sSL https:<span class=\"hljs-comment\">\/\/get.docker.com | sudo sh<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Wait for the installation to complete; at the end, you should receive an output similar to the one shown in the image below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-install-docker.jpg\"><img decoding=\"async\" width=\"962\" height=\"941\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-install-docker.jpg\" alt=\"Installing Docker on Raspberry Pi.\" class=\"wp-image-64246\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-install-docker.jpg 962w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-install-docker-380x372.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-install-docker-768x751.jpg 768w\" sizes=\"(max-width: 962px) 100vw, 962px\" \/><\/a><figcaption class=\"wp-element-caption\">Installing Docker on Raspberry Pi.<\/figcaption><\/figure>\n\n\n\n<p>That&#8217;s all. To confirm the running status of&nbsp;the Docker service, issue the following command:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo systemctl is-active docker<\/code><\/span><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-check-docker-service.jpg\"><img decoding=\"async\" width=\"923\" height=\"157\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-check-docker-service.jpg\" alt=\"Check service status.\" class=\"wp-image-64255\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-check-docker-service.jpg 923w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-check-docker-service-380x65.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-check-docker-service-768x131.jpg 768w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><\/a><figcaption class=\"wp-element-caption\">Check service status.<\/figcaption><\/figure>\n\n\n\n<p>As you can see, Docker is up and running as expected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Allow Non-Root User to Execute Docker Commands<\/h2>\n\n\n\n<p>So far, we have successfully installed Docker on our Raspberry Pi OS system. However, only root and users with&nbsp;<a href=\"https:\/\/linuxiac.com\/make-sudo-remember-password-longer\/\">sudo privileges<\/a>&nbsp;can execute Docker commands by default.<\/p>\n\n\n\n<p>So, if you now attempt to run the&nbsp;<code>docker<\/code>&nbsp;command without prefixing it with&nbsp;<code>sudo<\/code>, you\u2019ll get an output like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/docker-pemission-deniaed.jpg\"><img decoding=\"async\" width=\"924\" height=\"198\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/docker-pemission-deniaed.jpg\" alt=\"Trying to run the docker command as a regular user.\" class=\"wp-image-64258\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/docker-pemission-deniaed.jpg 924w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/docker-pemission-deniaed-380x81.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/docker-pemission-deniaed-768x165.jpg 768w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><\/a><figcaption class=\"wp-element-caption\">Trying to run the docker command as a regular user.<\/figcaption><\/figure>\n\n\n\n<p>But don\u2019t be concerned. There\u2019s a simple solution. To run Docker commands as a non-root user,&nbsp;<a href=\"https:\/\/linuxiac.com\/add-user-to-group-linux\/\">add your user to the \u201c<em>docker<\/em>\u201d group<\/a>. To do that, type in the following:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo usermod -aG docker ${USER}<\/code><\/span><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In the above command, ${USER} is an environment variable that holds your username. First, reboot your Raspberry Pi OS system to apply for the new group membership.<\/p>\n\n\n\n<p>Then, you can execute docker commands without prefixing them with sudo.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-as-regular-user.jpg\"><img decoding=\"async\" width=\"923\" height=\"177\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-as-regular-user.jpg\" alt=\"Run a Docker command as a regular user.\" class=\"wp-image-64261\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-as-regular-user.jpg 923w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-as-regular-user-380x73.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-as-regular-user-768x147.jpg 768w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><\/a><figcaption class=\"wp-element-caption\">Run a Docker command as a regular user.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Test the Docker Installation on Raspberry Pi<\/h2>\n\n\n\n<p>Now let\u2019s check if everything with our new Docker installation works properly. For this purpose, we will pull and run a simple container called \u201chello-world.\u201d<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">docker run hello-world<\/code><\/span><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-container.jpg\"><img decoding=\"async\" width=\"946\" height=\"725\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-container.jpg\" alt=\"Docker successfully installed, up &amp; running on raspberry Pi OS.\" class=\"wp-image-64264\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-container.jpg 946w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-container-380x291.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-run-docker-container-768x589.jpg 768w\" sizes=\"(max-width: 946px) 100vw, 946px\" \/><\/a><figcaption class=\"wp-element-caption\">Docker successfully installed, up &amp; running on Raspberry Pi OS.<\/figcaption><\/figure>\n\n\n\n<p>Congratulations! As we can see, everything works as expected!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Uninstall Docker on Your Raspberry Pi<\/h2>\n\n\n\n<p>If you decide to uninstall Docker from your Raspberry Pi system for any reason, you can do it easily by running the command below.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo apt remove docker-ce docker-ce-cli docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin<\/code><\/span><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-docker-uninstall.jpg\"><img decoding=\"async\" width=\"954\" height=\"392\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-docker-uninstall.jpg\" alt=\"Uninstall Docker on Raspberry Pi.\" class=\"wp-image-64279\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-docker-uninstall.jpg 954w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-docker-uninstall-380x156.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/pi-docker-uninstall-768x316.jpg 768w\" sizes=\"(max-width: 954px) 100vw, 954px\" \/><\/a><figcaption class=\"wp-element-caption\">Uninstall Docker on Raspberry Pi.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Installing Docker on a Raspberry Pi can be a great way to take advantage of the Pi&#8217;s capabilities as a low-cost, energy-efficient server.<\/p>\n\n\n\n<p>With Docker, you can easily set up and manage containers for various applications and services (<a href=\"https:\/\/linuxiac.com\/best-self-hosted-raspberry-pi-apps\/\" target=\"_blank\" rel=\"noreferrer noopener\">check out the best ones<\/a>) without worrying about compatibility issues or dependencies.<\/p>\n\n\n\n<p>We hope that this guide has helped get you started with Docker on your Raspberry Pi and that you can now take advantage of the many benefits that Docker offers.<\/p>\n\n\n\n<p>To learn more about Docker, check out the official&nbsp;<a href=\"https:\/\/docs.docker.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker documentation<\/a>. Additionally, we recommend&nbsp;<a href=\"https:\/\/linuxiac.com\/how-to-install-and-use-docker-compose\/\" target=\"_blank\" rel=\"noreferrer noopener\">our detailed guide<\/a>&nbsp;to expand your skills with Docker and learn how to run and manage multi-container applications using Docker Compose. Happy dockering!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ready to use Docker on your Raspberry Pi? Check out our easy-to-follow guide for a seamless installation and begin containerizing today.<\/p>\n","protected":false},"author":10,"featured_media":64210,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,4417],"tags":[1439,1869],"class_list":["post-64207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-linux-knowledge","tag-docker","tag-raspberry-pi"],"blocksy_meta":{"has_hero_section":"default","hero_section":"type-2","pageTitleFont":{"family":"Default","variation":"Default","size":{"desktop":"2.8em","tablet":"2.8em","mobile":"2.8em","__changed":[]},"line-height":"CT_CSS_SKIP_RULE","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"hero_elements":[{"id":"custom_title","enabled":true,"heading_tag":"h1","title":"Home","__id":"ntM_6BjGw_WML8pXWSuXQ"},{"id":"custom_description","enabled":false,"description_visibility":{"desktop":true,"tablet":true,"mobile":false},"__id":"RE9Whj3w94IC0pH3dUjxz"},{"id":"custom_meta","enabled":true,"meta_elements":[{"id":"author","enabled":true,"label":"By","has_author_avatar":"no","avatar_size":25,"__id":"uEheELp1RKBjATD-XCzFn"},{"id":"post_date","enabled":true,"label":"On","date_format_source":"default","date_format":"M j, Y","__id":"QR5q_a3r6SMDX-wUFSsb-"},{"id":"updated_date","enabled":false,"label":"On","date_format_source":"default","date_format":"M j, Y","__id":"GIWpcCnetE9VTtMDV1CTB"},{"id":"categories","enabled":false,"label":"In","style":"simple","__id":"_uyotKDRVPh6zR8Uk0HMg"},{"id":"comments","enabled":true,"__id":"9MuaJI7-gcVendcfYL20P"}],"page_meta_elements":{"joined":true,"articles_count":true,"comments":true},"__id":"BeaT2x4vBvGrDjlzpgpW9","meta_type":"label"},{"id":"breadcrumbs","enabled":false,"__id":"NRREQloVMNaSHqSPDSEgM"}],"hero_structure":"normal","page_title_bg_type":"custom_image","custom_hero_background":{"attachment_id":64213,"url":"https:\/\/linuxiac.com\/wp-content\/uploads\/2023\/05\/raspberry-pi-docker-header-1024x237.jpg"},"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/64207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/comments?post=64207"}],"version-history":[{"count":0,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/64207\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media\/64210"}],"wp:attachment":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media?parent=64207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/categories?post=64207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/tags?post=64207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}