{"id":129,"date":"2023-03-15T23:27:07","date_gmt":"2023-03-15T23:27:07","guid":{"rendered":"https:\/\/stuartglover.com\/2023\/03\/15\/installing-docker-and-portainer-on-a-raspberry-pi\/"},"modified":"2023-07-09T16:45:03","modified_gmt":"2023-07-09T16:45:03","slug":"installing-docker-and-portainer-on-a-raspberry-pi","status":"publish","type":"post","link":"http:\/\/iamglover.com\/?p=129","title":{"rendered":"Installing Docker and Portainer on a Raspberry Pi"},"content":{"rendered":"\n<p>Docker is a popular containerization platform that allows developers to deploy, manage, and run applications in containers. Running Docker on a Raspberry Pi can be a great way to experiment with containerization and create a portable development environment. In this blog post, we will walk through the steps to install Docker and Portainer on a Raspberry Pi.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before you start, you will need the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Raspberry Pi running Raspberry Pi OS (Raspbian) with a working internet connection<\/li>\n\n\n\n<li>SSH access to the Raspberry Pi<\/li>\n\n\n\n<li>Basic knowledge of the Linux command line<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Update and Upgrade the Raspberry Pi<\/h2>\n\n\n\n<p>Before we install Docker and Portainer, we need to update and upgrade the Raspberry Pi to ensure that we have the latest software packages. To do this, open the terminal on the Raspberry Pi or connect to it using SSH and run the following commands:<\/p>\n\n\n\n<p><code class=\"!whitespace-pre hljs language-sql\">sudo apt update<\/code><br><code class=\"!whitespace-pre hljs language-sql\">sudo apt upgrade<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Docker<\/h2>\n\n\n\n<p>Next, we need to install Docker on the Raspberry Pi. To do this, we will use the convenience script provided by Docker. Run the following command in the terminal to download and run the script:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-vbnet\">curl -fsSL https:\/\/get.docker.com -o get-docker.sh &amp;&amp; sh get-docker.sh<\/code><br><\/pre>\n\n\n\n<p>This script will download and install the latest version of Docker on your Raspberry Pi.<\/p>\n\n\n\n<p>Once Docker is installed, you can verify the installation by running the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">s<code class=\"!whitespace-pre hljs\">udo docker version<\/code><br><\/pre>\n\n\n\n<p>This will display the version of Docker installed on your Raspberry Pi.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Add User to the Docker Group<\/h2>\n\n\n\n<p>By default, the Docker daemon runs as the root user, which means that any Docker container has full access to the host system. To avoid security issues, we will add the current user to the Docker group so that we can run Docker commands without using sudo.<\/p>\n\n\n\n<p>Run the following command to add the current user to the Docker group:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-javascript\">sudo usermod -aG docker $(whoami)<\/code><br><\/pre>\n\n\n\n<p>Note that you will need to log out and log back in for the changes to take effect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Install Portainer<\/h2>\n\n\n\n<p>Portainer is a lightweight management UI that allows you to easily manage Docker containers, images, networks, and volumes. To install Portainer, we will create a Docker volume and then start a Portainer container.<\/p>\n\n\n\n<p>First, create the Docker volume using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-lua\">sudo docker volume create portainer_data<\/code><br><\/pre>\n\n\n\n<p>Next, start the Portainer container using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code class=\"!whitespace-pre hljs language-javascript\">sudo docker run -d -p 8000:8000 -p 9000:9000 --name portainer --restart always -v \/var\/run\/docker.sock:\/var\/run\/docker.sock -v portainer_data:\/data portainer\/portainer-ce<\/code><br><\/pre>\n\n\n\n<p>This command will start a new Portainer container with the name &#8220;portainer&#8221; and expose ports 8000 and 9000. The container will automatically restart if it stops, and it will use two Docker volumes: one for the Docker socket and one for Portainer data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Access Portainer<\/h2>\n\n\n\n<p>Once the Portainer container is running, you can access the Portainer UI by opening a web browser and navigating to the IP address of your Raspberry Pi on port 9000. For example, if your Raspberry Pi&#8217;s IP address is 192.168.1.100, you would navigate to <a href=\"http:\/\/192.168.1.100:9000\/\">http:\/\/192.168.1.100:9000<\/a>.<\/p>\n\n\n\n<p>You will be prompted to create an admin user for Portainer. After you create the admin user, you can start using Portainer to manage your Docker containers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>In this blog post, we walked through the steps to install Docker and Portainer on a Raspberry Pi.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker is a popular containerization platform that allows developers to deploy, manage, and run applications in containers. Running Docker on a Raspberry Pi can be a great way to experiment with containerization and create a portable development environment. In this blog post, we will walk through the steps to install Docker and Portainer on a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker"],"jetpack_featured_media_url":"http:\/\/iamglover.com\/wp-content\/uploads\/2023\/03\/portainer.jpg","_links":{"self":[{"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/iamglover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":1,"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":181,"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions\/181"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iamglover.com\/index.php?rest_route=\/wp\/v2\/media\/144"}],"wp:attachment":[{"href":"http:\/\/iamglover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iamglover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iamglover.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}