{"id":43,"date":"2022-09-28T22:34:47","date_gmt":"2022-09-28T20:34:47","guid":{"rendered":"https:\/\/blog.douwedevri.es\/?p=43"},"modified":"2025-02-19T01:04:41","modified_gmt":"2025-02-18T23:04:41","slug":"portainer-community-edition","status":"publish","type":"post","link":"https:\/\/blog.dbdv.nl\/?p=43","title":{"rendered":"Portainer Community Edition"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial works for&nbsp;<strong>Linux&nbsp;<\/strong>systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the next instructions to work, the following packages must be installed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>docker<\/code><\/li>\n\n\n\n<li><code>vim<\/code> (or any other text-editor)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Install Portainer CE<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, let&#8217;s install Portainer!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">docker run -d -p 9000:9000 --name portainer --restart=always -v \/var\/run\/docker.sock:\/var\/run\/docker.sock -v portainer_data:\/data portainer\/portainer-ce:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It will download the latest <strong>portainer-ce<\/strong> image and run it on port 9000.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Portainer CE is the Community Edition. It is the free and open source variant. Visit <a href=\"https:\/\/github.com\/portainer\/portainer\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/portainer\/portainer<\/a> for the source code. Alternatively, there is the <a href=\"https:\/\/portainer.io\" data-type=\"URL\" data-id=\"https:\/\/portainer.io\" target=\"_blank\" rel=\"noreferrer noopener\">Business Edition<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update Portainer<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Next up: Let&#8217;s make it easier to update Portainer&#8230; in the future.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/blog.douwedevri.es\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-1024x702.png\" alt=\"\" class=\"wp-image-60\" srcset=\"https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-1024x702.png 1024w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-300x206.png 300w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-768x526.png 768w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-1536x1053.png 1536w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10-1568x1075.png 1568w, https:\/\/blog.dbdv.nl\/wp-content\/uploads\/2022\/09\/Screenshot-2022-09-28-at-22.36.10.png 1684w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Updating Portainer CE using a script<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To simplify the update process, we will make two scripts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first script will <strong>install<\/strong> Portainer. This script makes use of the same command we ran earlier. The second script will <strong>update<\/strong> Portainer and inherits the install script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">#!\/bin\/sh\n\ndocker run -d -p 9000:9000 --name portainer \\\n--restart=always \\\n-v \/var\/run\/docker.sock:\/var\/run\/docker.sock \\\n-v portainer_data:\/data \\\nportainer\/portainer-ce:latest<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Call the above script <code>install_portainer.sh<\/code>. To make the file executable run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">chmod +x install_portainer.sh<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now for the second script. To actually update a running container, we first need to <strong>stop<\/strong> and <strong>remove<\/strong> it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The data, such as login credentials, will not be removed. Those are stored in the volume <code>portainer_data<\/code>, as you can see in the <code>install_portainer.sh<\/code> script.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the container is removed we can <strong>pull<\/strong> the most up-to-date (latest) image, and install.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After the new container is running we will remove all dangling images. This will ultimately remove the old image form the system. See the script below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">#!\/bin\/sh\n\ndocker container stop portainer\ndocker container rm portainer\n\ndocker image pull portainer\/portainer-ce:latest\n\n.\/install_portainer.sh\n\ndocker image prune<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Call this script <code>update_portainer.sh<\/code>. Like the last script, use the following command to give it execution rights.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">chmod +x update_portainer.sh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Troubleshooting<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When this is the first time using docker. It is possible that an error accuses along the lines of:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\" line-numbers\">Got permission denied while trying to connect to the Docker daemon socket at unix:\/\/\/var\/run\/docker.sock: Get http:\/\/%2Fvar%2Frun%2Fdocker.sock\/v1.39\/containers\/json: dial unix \/var\/run\/docker.sock: connect: permission denied<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In that case the user does not have the correct permissions. To resolve this problem, add the user to the <code>docker<\/code> group.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">usermod -aG docker $USER<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To make the changes go into effect, log out and back in again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Docker compose<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, portainer can be installed using docker compose. Create a file called docker-compose.yml with the following content.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">services:\n  portainer:\n    container_name: portainer\n    image: portainer\/portainer-ce:latest\n    restart: always\n    ports:\n      - 9000:9000\n    volumes:\n      - \/var\/run\/docker.sock:\/var\/run\/docker.sock\n      - portainer_data:\/data\n\nvolumes:\n  portainer_data:<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, run <code>docker compose up -d<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prerequisites This tutorial works for&nbsp;Linux&nbsp;systems. For the next instructions to work, the following packages must be installed: Install Portainer CE First, let&#8217;s install Portainer! It will download the latest portainer-ce image and run it on port 9000. Portainer CE is the Community Edition. It is the free and open source variant. Visit https:\/\/github.com\/portainer\/portainer for the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":55,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[7,5,8],"class_list":["post-43","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-docker","tag-linux","tag-portainer"],"_links":{"self":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=43"}],"version-history":[{"count":25,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/43\/revisions"}],"predecessor-version":[{"id":240,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/43\/revisions\/240"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}