Mastodon Skip to main content

Installing Portainer-CE and / or Portainer Agent

I'm making this as an update to my Portainer video that is now easily more than a year and a half old.  The good news is that the old video for Portainer install is really the same as this one will be, except that since the original video the Portainer team split the project into Portainer (a more advanced version of the software available to those who license it), and Portainer-CE (Community Edition) the fully open source version that eventually gets some of those more advanced features.  

For my uses and needs as a homelab user, Portainer-CE works just fine, and is a tremendous tool for managing my docker containers.

The second part of this tutorial is about installing Portainer Agent.  An agent software that allows the fully installed Portainer-CE to act as a frontend for your Docker containers on other host machines.  I also did an older video on how to use Portainer in this way, in particular with a Raspberry Pi as the secondary host, but it was, at best, clunky to get setup and working.  Portainer Agent, however, is a much simpler, and more straight-forward install.  

Additionally, I took the time to provide a good overview of the features in Portainer-CE / Portainer Agent, and it has gotten so much better since my original video.   I hope you'll enjoy this, and follow along in the video to get everything running.  

For those who prefer text instructions, keep reading.

Installing Portainer CE on your Host Machine

The commands I'm about to provide, are available on the Portainer Documentation site as well.

NOTE: You must have Docker installed already.  Docker does not get installed with Portainer, but instead Portainer-CE runs in Docker.

Now that you're ready, you'll want to run the following commands in the terminal of your selected Linux distro that's already got Docker (I prefer Docker-CE) installed.

  1. Setup a Portainer data volume.
docker volume create portainer_data

2. Install Portainer CE

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

Note - You can change the ports for both 8000, and 9000 on your host, by changing the port number on the left side of the colon in the command above.  If you already have something using either port 8000 and / or port 9000 on your host, then you should change these port numbers.  I only recommend that you do not use port 9001, as this is the port used for Portainer Agent.  

Once you run the command above, you can now navigate to your host machine's IP address and port 9000 to go through the admin first-time login process.

for me it was

http://192.168.7.125:9000

You should use the IP of your host machine, of course.

Install Portainer Agent on a Secondary Host

If you'd like to control more than one host running Docker containers, then Portainer Agent to the rescure.  You install Portainer Agent on any secondary host machines, then add them to your main Portainer machine via the Portainer-CE UI.  Nice, right?

NOTE: Again, you should have Docker already installed and running on these hosts, as Portainer, Portainer-CE, and Portainer Agent do not install docker, but instead run inside docker as their own containers.

To install Portainer Agent, run the following command on the terminal of your secondary host machine's.

docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent

Again, you can change the port if need be, by changing the port number on the left side of the colon in the command above.

Allow the container to install and start running, then from your main Portainer-CE install, navigate in the left pane to "Endpoints".

Click the "+ Add New Endpoint" button at the top of the screen, then enter the Name for the endpoint that makes the machine easy to identify, the local IP address and port 9001 (like 192.168.7.51:9001 ) in the Endpoint URL and Public IP address fields, add the host to any groups you have setup, and add any tags to the host you desire, then click the "+ Add Endpoint" button at the bottom of the form.

If you entered everything correctly, you'll see a list of hosts show up on the Endpoints screen.  

You can now access your local Portainer-CE install, as well as any Portainer Ageny machines you've added right from the UI on the Portainer-CE host.

Just click the 'Home' option in the left pane to switch between hosts, as well as see an overview of their statuses (up / down).

Support my Channel and Content

Support my Channel and ongoing efforts through Patreon:
https://www.patreon.com/bePatron?u=234177