Imagine having multiple devices running Docker containers. How do you effectively manage all these containers? Personally, I’ve found the solution with Portainer. I can have a master running the main program and multiple agents running on the devices. In this blog post, I will explain various setups that are possible.

Portainer

Portainer is a lightweight service delivery platform for containerized applications that can be used to manage Docker, Swarm, Kubernetes and ACI environments. It is designed to be as simple to deploy as it is to use. The application allows you to manage all your orchestrator resources (containers, images, volumes, networks and more) through a ‘smart’ GUI and/or an extensive API.

Choose the correct setup

There are a few different setups that you can use depending on your requirements:

  • install the Portainer Agent on the Docker Standalone host and connect via the agent
  • connect directly to the Docker API or the Docker socket
  • deploy the Portainer Edge Agent in standard or async mode

Which setup did I choose to control my Raspberry Pis at home? I opted for the Portainer Edge Agent in standard mode since async mode is only available in Portainer Business Edition, which is more suitable for environments with limited or intermittent connectivity. Why did I choose this? For me, the setup using the Docker API or Docker socket was not practicable because I didn’t want to modify the Docker configs or expose the Docker API. Why didn’t I choose the Portainer Agent? The reason is that with the Portainer Agent, the Portainer Server needs to be in the same network as the Portainer Agents, as it is the server that establishes the connection with the Agents (a port needs to be open). In contrast, with the Portainer Edge Agent, it’s the Edge Agents that establish the connection with the Portainer Server(doesn’t need any ports opened). With the following diagram, I believe it will be clearer to understand the difference between these two setups: portainer agent Reference: https://docs.portainer.io/start/architecture

Configurations

To start with the configurations, first you need to create a new environment in the Portainer Server: portainer agent setup 1

In the Edge Agent insert the current IP/Domain of your Portainer Server: portainer agent setup 2

After copying the docker commands (in red) and run them in the Edge Device will be able to see the data like the following image in the Home view(server): portainer agent setup 3

Portainer also has groups and tags that can be plus when dealing with a large number of Edge Devices, providing an efficient way to organize and manage them.