Running Portainer CE on a QNAP NAS

Matthias Seifert
May 2 · 3 min read

Portainer is my favourite tool to manage docker containers because it provides a simple, yet powerful graphical user interface. But running it on my QNAP NAS was not as straight forward as I first thougt it would be. This blog post shows one way to run Portainer CE to manage containers on a QNAP NAS.

The first opportunity for me to use Portainer was to manage containers running on a Raspberry Pi. And since I was really happy with setup and use on the Pi, Portainer was my tool of choice to manage containers on my QNAP NAS.

Photo by Freddie on Unsplash

At first, setting up the Portainer CE container on the NAS seemed largely straight-forward: Create a new container using ContainerStation, select the portainer/portainer-ce:latest image and give it a name. Then select the necessary ports, create and mount a volume for persistent data, and mount the UNIX socket at /var/run/docker.sock.

But at this point I ran into a problem that almost stopped me. ContainerStation would not let me enter a path to mount nor would it let me select the socket at /var/run/docker.sock .

My first idea was to tamper with the source code of the web-ui using the Chrome DevTools.

Screenshot of the input field for the path on the NAS with the readonly attribute highlighted
Screenshot of the input field for the path on the NAS with the readonly attribute highlighted
Screenshot of the page source. Removing “readonly” allows to enter free text for the Mount Point.

Removing the readonly attribute would then let me enter the desired path.

Screenshot of the input field for the local path kafter editing the page source and entering /var/run/docker.sock
Screenshot of the input field for the local path kafter editing the page source and entering /var/run/docker.sock
Screenshot of ContainerStation with /var/run/docker.sock to be mounted

Things looked good when the volume mount was also listed in the summary.

Screenshot of the volumes mounted into the container containing /var/run/docker.sock
Screenshot of the volumes mounted into the container containing /var/run/docker.sock
Host-Volumes to be mounted into the container

But all hope was gone when Portainer could not connect to the docker socket on startup.

Error message of Portainer stating “Failure. Unable to initiate communications with endpoint.”
Error message of Portainer stating “Failure. Unable to initiate communications with endpoint.”
Obviously Portainer could not connect to the docker socket

A new idea was needed. Why not try the simplest way and run the container for Portainer directly from the shell ?

After connecting to the NAS through putty, running docker -v confirmed that docker was available from the shell.

[~] # docker -v
Docker version 20.10.5, build 55c4c88

The next step is to create the persistent volume and run the container:

[~] # docker volume create portainer
portainer
[~] # docker run -d --restart=unless-stopped -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer:/data --name portainer portainer/portainer-ce:latest
8f0e2f76e22b43e2855189877e7dc1e1e7d98c226c95db247cd1d547928334a9

Opening the web browser athttp://<NAS-IP>:9000 shows that Portainer is running. Once it is configured to manage the local docker instance, the Home screen shows up and reveals one running container — Portainer itself.

Screenshot of Portainer ready to manage containers and images

Bingo! Obviously the simplest solution actually did the job.

Portainer is runing, connected to the docker daemon on the NAS and happily ready to manage containers.

Thank you for reading. I hope this blog post could help you setting up Portainer CE. If you have any comments, suggestions, or questions please leave a comment, drop me a message on medium, or DM me on twitter.

If you would like to read more interesting blog posts, not only about running Portainer on your NAS, take a look at our company blog.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store