Docker Day #1: Portainer, your Docker container manager

Docker Day is a new segment on this website in which provides you a short and, hopefully, easy to follow tutorial on how to install an app using Docker. On today's Docker day we are learning how to install Portainer in a Docker environment (specifically in a Synology environment) !

Docker Day #1: Portainer, your Docker container manager
Photo from ByteLanguage.net

Table of contents:

  1. What's Docker Day?
  2. What's Portainer?
  3. Why Portainer and not (Synologys) Docker Hub?
  4. Portainer Installation options
  5. Installing Portainer
  6. Final words

So, what's this Docker Day, you ask?

^   back to top   ^

It's a new segment on this website that I hope you'll enjoy. In it, I will always give a short tutorial on how you can install an app using Docker. The goal is to have a Docker day - and thus a new tutorial - every week!

I use a Synology Diskstation with Docker installed. That means that these tutorials are often gonna be more geared towards Synology Users. Nonetheless, due to the nature of Docker, they should be helpful for anybody using Docker even if your underlying environment is slightly different.

But enough of the introduction, let's get going !

On today's Docker Day, we will learn how to install Portainer. This one will be a long one, but trust me, once you've set up Portainer, setting up almost any Docker application will be as easy as a copy & paste in a GUI text box. So, in my opinion, it is worth going through the trouble once.

What's portainer?

^   back to top   ^

Portainer is a lightweight management UI which allows you to easily manage your Docker environments. It allows you to manage your Docker containers, images, volumes, networks, and more, all from a web-based interface.

Some of the key features of Portainer include:

Easy setup and installation: Portainer can be easily installed on any system that has Docker installed, and its web-based interface makes it easy to get started managing your Docker environment.

Intuitive interface: Portainer has a clean and intuitive interface that makes it easy to navigate and manage your Docker environment.

Multi-platform support: Portainer supports a wide range of platforms, including Windows, Linux, and MacOS.

Container management: Portainer allows you to easily manage your Docker containers, including starting, stopping, and restarting them, as well as viewing logs and other information about each container.

Image management: Portainer makes it easy to manage your Docker images, including pulling images from Docker Hub, pushing images to Docker Hub, and building images from Dockerfiles.

Volume management: Portainer allows you to manage your Docker volumes, including creating, attaching, and detaching volumes, as well as viewing the contents of volumes.

Network management: Portainer allows you to manage your Docker networks, including creating, attaching, and detaching networks, as well as viewing network information and statistics.

Overall, Portainer is a powerful tool for managing Docker environments, and its user-friendly interface makes it easy to get started with Docker.


Why would I use Portainer over (Synology's) Docker Hub ?

^   back to top   ^

While the Docker app on Synology NAS provides a convenient way to manage your Docker containers, it has some limitations compared to using Portainer. Some of the reasons why you might want to use Portainer instead of the regular Docker app include:

  • Portainer has a more user-friendly interface: The Docker app on a Synology NAS has a more technical interface, which can be daunting for users who are not familiar with Docker. In contrast, Portainer has a clean and intuitive interface that makes it easy to manage your Docker environment, even for users who are new to Docker.
  • Portainer offers more features and functionality: The Docker app on Synology NAS provides the basic functionality you need to manage your Docker containers, such as starting and stopping containers, viewing logs, and so on. However, Portainer offers additional features and functionality that can make it easier to manage your Docker environment, such as image and volume management, network management, and support for Docker Compose.
  • Portainer can manage multiple Docker hosts: If you have multiple Docker hosts (e.g., multiple Synology NAS devices or other systems), the Docker app on a Synology NAS can only manage the Docker environment on the local host. In contrast, Portainer can be used to manage multiple Docker hosts from a single web-based interface, which can be useful if you have a large or distributed Docker environment.

Overall, Portainer provides a more comprehensive and user-friendly way to manage your Docker environment and it offers a number of additional features and functionality that can make it easier to manage your Docker containers, images, volumes, and networks.


Which options do I have to install Portainer ?

^   back to top   ^

There's multiple ways you can go about installing Portainer. You can install it via...

  1. ... Synology's Docker application interface, the Docker Hub (Synology-specific).
  2. ...running a docker command as a scheduled task (Synology-specific).
  3. ...running a docker command as a sudo user in the CLI/Terminal.
  4. ...running a docker compose file as a sudo user in the CLI/Terminal.

It is up to you which route you want go. However, the last three options involve using root user or sudo user access. In general, these options are not recommended for users unfamiliar with using the terminal because there is a small chance you might brick your entire NAS, if you do not know what you are doing. We will not cover option 3 and 4 in this tutorial but if you are interested in them, drop me a comment and I'll add them.

Before we continue, make sure that you have decided on two available ports in your network. Per default, Portainer will use 8000 and 9000 which correspond to the internal ports. However, you can map them to some other port in case you don't want to use these ports or they are already used otherwise.

Installing Portainer

^   back to top   ^

1. ... Synology's Docker application interface, the Docker Hub

While this is the most cumbersome method, it may also be the most self-explanatory approach to installing Portainer thanks to the Synology Docker Hub GUI.

Here is how you install Portainer via the Docker Hub:
  1. Open the Docker app on your Synology NAS and go to the Registry tab.
  2. In the search bar, type "portainer/portainer-ce" and press Enter.
  3. Click on the Portainer image and then click the Download button. Make sure you download the latest image.
  4. After the image has been downloaded, go to the Image tab and find the Portainer image in the list.
  5. Select the Portainer image and click the Launch button.
  6. In the new window, ensure that there is a checkmark only in front of the "bridge" network and click on Next. Select a name for your container or leave on default and check Enable auto-restart.
  7. Click the Advanced Settings tab and go to the Environment section. If it does not already exist, add a variable PATH with the value /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. Click on Save.
  8. In the Port Settings section, map Local Port 8000 to Container Port 8000 and Local Port 9000 to Container Port 9000. If you have chosen other ports, feel free to change the local ports.
  9. Click the Volume Settings section add a local folder from you NAS. I recommend a "portainer-ce" subfolder in a "docker" folder. Set it's mount path to /data. Click on Next.
  10. Click on Done.

Once the container has been created, you can access the Portainer web interface by going to http://your-nas-ip-address:your-port/ in your web browser. From there, you can manage your Docker containers and images using the Portainer interface.

2. ... running a Docker command as a scheduled task

This one is fairly straight-forward for DSM. However, it requires you to wield your root user power.  To prevent the, albeit small, risk of messing with your NAS in such a way that you'd need to set everything back up again, make sure that you are going to copy the correct Docker commands.

Here's how you install Portainer via a scheduled task:
  • In Synology's DSM GUI, navigate to the Control Panel and click on Task Scheduler under Services.
  • Click on Create on the top left of the window and create a new task with Scheduled Task and then User-defined script.
  • In the newly opened window, you can give the task a descriptive name in the General settings if you want. Importantly, you need to set User to root.
  • Then navigate to the Task Settings panel and paste the code from below into the Run command text box.
docker run -d --name=portainer-ce \
-p 8000:8000 \
-p 9000:9000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /volume1/docker/portainer-ce:/data \
--restart=always \
portainer/portainer-ce:latest
Docker command to install Portainer via a scheduled task

The flag -p stands for the port, where the first value before the colon indicates the port it will respond to. We define two ports, but to actually get to the GUI of Portainer, you will need to access the 9000 port (unless you have mapped it to another port).  

  • In this Task Settings panel, you can also add your email address to be notified about the result of running the task. It will send you an email with either a success or failure message and some logging.
  • You can also go to the Schedule panel and set Run on the following date to a specific date and time if you prefer that.
  • Otherwise, you are ready to go and can press OK. After a short while, Portainer should be installed.

Once the container has been created, you can access the Portainer web interface by going to http://your-nas-ip-address:your-port/ in your web browser. From there, you can manage your Docker containers and images using the Portainer interface.


Are we done, yet?

^   back to top   ^

Not quite: once you've installed Portainer and navigated to its IP address:

  • You will have to create an account, choose a password and click on "Create user".
  • In the next screen, select Docker and then connect.
  • Finally, click on local to manage your local Docker environment.
  • All is set up and you are ready to use your Portainer app!

Okay, that was a lot of information and ... just stuff in general. Nevertheless, let me assure you that it was worth it. Now that everything is set up, deploying and managing your containers, will be so much easier! How much easier, you will find out next week when we look at the next Docker application to install.

If you are wondering how to use Portainer, I'll let you know a few things as part of the Docker Day series. However, an in-depth tutorial is beyond the scope of this post. I can highly recommend to check out the Portainer documentation and go through the 101 Tutorials.

Hopefully, this tutorial provided you some value and I hope I'll read you on next week's Docker day!