{"id":68,"date":"2017-07-03T00:00:00","date_gmt":"2017-07-03T00:00:00","guid":{"rendered":"http:\/\/ssdnodes.billabailey.com\/2017\/07\/03\/tutorial-easier-docker-management-with-portainer\/"},"modified":"2025-05-18T13:21:26","modified_gmt":"2025-05-18T13:21:26","slug":"portainer-docker-management","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/portainer-docker-management\/","title":{"rendered":"Using Portainer To Manage Your Docker Containers Easily"},"content":{"rendered":"<p>We hope that with all the <a href=\"https:\/\/www.ssdnodes.com\/blog\/tag\/docker\/\">Docker tutorials<\/a> and our <a href=\"https:\/\/www.ssdnodes.com\/blog\/self-hosting-handbook\/\">self-hosting handbook<\/a>, we hope that many you are practically swimming in Docker containers. Docker makes the task of running a lot of applications on a single VPS a lot easier, but even if you run just a few WordPress blogs, you'll end up with 6, 8, 10, or more containers running concurrently. No matter how intelligent your naming scheme, the sheer volume makes managing them tricky.<\/p>\n<p>Enter\u00a0<a href=\"https:\/\/github.com\/portainer\/portainer\" target=\"_blank\" rel=\"noopener\">Portainer<\/a>, which bills itself as a lightweight management UI for easier management of a Docker host or Swarm cluster. It's a single container that can run on any Docker host, and helps you manage all of your containers, images, volumes, networks, and more.<\/p>\n<p>In this tutorial, we'll cover the process of installing Portainer, and figure out how to do some basic maintenance.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>A VPS running any of our OS options<\/li>\n<li>A working Docker installation\u2014for information about how to install Docker, check out our\u00a0<a href=\"https:\/\/www.ssdnodes.com\/blog\/getting-started-docker-vps\/\">getting started with Docker tutorial<\/a>.<\/li>\n<\/ul>\n<div class=\"cta-inline\"><\/div>\n<h2>Step 1. Installing Portainer<\/h2>\n<p>Because Portainer runs inside of a Docker container itself, installation is pretty straightforward. Although you don't have to set up Portainer so that it forces SSL over connections to the web portal, that's the method we're going to cover\u2014simply put, if you're using Portainer to manage production Docker containers, you'll want to ensure that connections are secure. Plus, it's just good practice.<\/p>\n<p>We're also going to set up Portainer so that data can be persisted between reboots.<\/p>\n<p>This is more complex than the baisc installation process\u00a0<code>docker run -d -p 9000:9000 portainer\/portainer<\/code>, but will be safer and more maintainable.<\/p>\n<h3>Creating SSL keys<\/h3>\n<p>Before we can move forward, let's create the keys necessary to run Portainer in SSL mode. When you enter the final command, you'll be asked to input some information about how to sign the key, which you can fill out to your discretion.<\/p>\n<p><em>Note: If you're running Portainer on a production machine, you probably already have (signed) SSL certificates available to use instead of these self-signed ones. Or, if you don't have them already, you can set up something like\u00a0<a href=\"https:\/\/certbot.eff.org\/\" target=\"_blank\" rel=\"noopener\">Certbot<\/a>. However, for the sake of simplifying this tutorial to accommodate the most installations, we'll just cover self-signed certificates.<\/em><\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> mkdir <span class=\"hljs-built_in\">local<\/span>-certs &amp;&amp; <span class=\"hljs-built_in\">cd<\/span> <span class=\"hljs-built_in\">local<\/span>-certs<\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> openssl genrsa -out portainer.key 2048<\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> openssl ecparam -genkey -name secp384r1 -out portainer.key<\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> openssl req -new -x509 -sha256 -key portainer.key -out portainer.crt -days 3650<\/span>\n<\/code><\/pre>\n<p>Now that we have our SSL keys in hand, we can move forward with the Portainer installation.<\/p>\n<h3>Installing Portainer<\/h3>\n<p>As previously mentioned, we're going to set up Portainer to use SSL\u00a0<em>and<\/em>\u00a0persist the information, so the command will be significantly more complex than the aforementioned default.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> docker run <span class=\"hljs-_\">-d<\/span> -p 443:9000 -v ~\/<span class=\"hljs-built_in\">local<\/span>-certs:\/certs -v ~\/portainer:\/data -v \/var\/run\/docker.sock:\/var\/run\/docker.sock portainer\/portainer --ssl --sslcert \/certs\/portainer.crt --sslkey \/certs\/portainer.key<\/span>\n<\/code><\/pre>\n<p>Let's break that command down at little bit.<\/p>\n<pre><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> docker run <span class=\"hljs-_\">-d<\/span> <\/span><strong><span class=\"bash\">-p 443:9000<\/span><\/strong><span class=\"bash\"> -v ~\/<span class=\"hljs-built_in\">local<\/span>-certs:\/certs -v ~\/portainer:\/data -v \/var\/run\/docker.sock:\/var\/run\/docker.sock portainer\/portainer --ssl --sslcert \/certs\/portainer.crt --sslkey \/certs\/portainer.key<\/span>\n<\/code><\/pre>\n<p>This sets up Portainer to listen to traffic on port\u00a0<code>443<\/code>\u00a0(the port for SSL), and forwards that traffic to port\u00a0<code>9000<\/code>\u00a0within the container.<\/p>\n<pre><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> docker run <span class=\"hljs-_\">-d<\/span> -p 443:9000 <\/span><strong><span class=\"bash\">-v ~\/<span class=\"hljs-built_in\">local<\/span>-certs:\/certs -v ~\/portainer:\/data -v \/var\/run\/docker.sock:\/var\/run\/docker.sock<\/span><\/strong><span class=\"bash\"> portainer\/portainer --ssl --sslcert \/certs\/portainer.crt --sslkey \/certs\/portainer.key<\/span>\n<\/code><\/pre>\n<p>The\u00a0<code>-v<\/code>\u00a0option sets up volumes containing data that's meant to be shared between the host and the container. There are three volumes in question here, the first of which is\u00a0<code>~\/local-certs<\/code>, which is where we saved our SSL certificates, and the second of which binds\u00a0<code>~\/portainer<\/code>\u00a0on the host to the\u00a0<code>\/data<\/code>\u00a0folder inside the container. The third connects this container to the host's socket.<\/p>\n<p>The values before the colon (<code>:<\/code>) in the first two volumes can be changed if need be.<\/p>\n<pre><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> docker run <span class=\"hljs-_\">-d<\/span> -p 443:9000 -v ~\/<span class=\"hljs-built_in\">local<\/span>-certs:\/certs -v ~\/portainer:\/data -v \/var\/run\/docker.sock:\/var\/run\/docker.sock portainer\/portainer <\/span><strong><span class=\"bash\">ssl --sslcert \/certs\/portainer.crt --sslkey \/certs\/portainer.key<\/span><\/strong>\n<\/code><\/pre>\n<p>Finally, this portion of the command tells Portainer where to look for the certificates it needs to enable SSL.<\/p>\n<p>So, once you run this command, Docker will download the Portainer image (unless you happen to have it already), and launch the container.<\/p>\n<h2>Step 2. Connecting to the Portainer web interface<\/h2>\n<p>We're finally ready to connect to the web interface. To do so, open your favorite browser and navigate to\u00a0<code><a href=\"https:\/\/YOUR_SERVER_IP\/\" target=\"_blank\">https:\/\/YOUR_SERVER_IP\/<\/a><\/code>. You'll probably get a warning from your browser about the certificate being insecure because it's not signed by a certificate authority. That's true, but since you're using only using this for administration and not for anyone else accessing thes server, it's safe to move forward\u2014the connection is still encrypted, but only with your self-signed key.<\/p>\n<p>You'll first see a prompt asking you to set an admin password.<\/p>\n<p><img decoding=\"async\" title=\"The password creation screen\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/01\/20170703_portainer_1.png\" alt=\"The password creation screen\" \/><\/p>\n<p>After that, you'll see a standard login screen. Your username will be\u00a0<code>admin<\/code>, and the password is what you just set.<\/p>\n<p><img decoding=\"async\" title=\"The password creation screen\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2017\/07\/20170703_portainer_2-1.png\" alt=\"The password creation screen\" \/><\/p>\n<p>Finally, you'll be prompted about how you want Portainer to connect to the Docker engine. You want to click the selector next to\u00a0<strong>Manage the Docker instance where Portainer is running<\/strong>, and then hit\u00a0<strong>Connect<\/strong>.<\/p>\n<p><img decoding=\"async\" title=\"Connecting Portainer to the Docker engine\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/01\/20170703_portainer_3-1.png\" alt=\"Connecting Portainer to the Docker engine\" \/><\/p>\n<p>After a moment, you'll be directed to the management interface.<\/p>\n<h2>Step 3. Basic container management via Portainer<\/h2>\n<p>Much of the Portainer interface is best left to exploration, but let's cover a number of interesting elements and things you might not be aware of straightaway. Starting from the dashboard (below), you can see the status of all of your containers, images, volumes, networks, and more.<\/p>\n<p><img decoding=\"async\" title=\"The Portainer dashboard\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2017\/07\/20170703_portainer_4.png\" alt=\"The Portainer dashboard\" \/><\/p>\n<p>Let's quickly walk through the process of creating a new Docker container using the Portainer interface.<\/p>\n<p>First, click on the\u00a0<em>App Templates<\/em>\u00a0link in the navigation, and look for MySQL in the list of templates. Then, give it a logical name and enter a secure root password.<\/p>\n<p><img decoding=\"async\" title=\"Getting the MySQL container set up\" src=\"https:\/\/www.ssdnodes.com\/wp-content\/uploads\/2024\/01\/20170703_portainer_5.png\" alt=\"Getting the MySQL container set up\" \/><\/p>\n<p>After yours is configured similar, you can go ahead and click &quot;Create.&quot; You'll be redirected to the containers status page, where you'll be able to see the MySQL container running. By clicking on the container's name, you can enter its specific administration area, where you can view logs, connect to the container via a console, restart the container, kill it, remove it, and more.<\/p>\n<p>We hope this tutorial has been useful for those who want better container management! If you have questions or ideas for interesting things you can do after being empowered with Portainer, lets us know in the comments.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker makes the task of managing VPS a lot easier, but Portainer takes it a step further. View real-time data and administer via an easy web interface.<\/p>\n","protected":false},"author":20,"featured_media":2916,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18,30],"tags":[182,272],"class_list":["post-68","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-tutorials","tag-docker","tag-portainer"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":3,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":13021,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/68\/revisions\/13021"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/2916"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}