Portainer is a self-hosted service I was lucky enough to find early on in my docker journey. It is a container which helps you manage your other containers, and frankly, life would have been a lot more difficult without it.
Having said that, maybe you're fine with the Synology Docker GUI, or are a whiz on SSH and it suits your needs. But I love Portainer, and I love spreading the love.
In this article I'll take you through the steps to set it up, and give you a broad overview of the various tools you'll have available to you.
for any command starting with
docker, to avoid permissions issues you either need to write
sudobefore it, or you can follow this guide (scroll to point 6) to add your user to the docker group which means you will no longer need to add
First up, we need to create the container, and we'll use our trusty docker-compose for this:
- Login to your NAS via SSH and create your portainer network (skip this step if you just plan to use the default bridge network)
docker network create portainer
- In your file manager (either File Station or SMB via Windows 10 etc.) create your docker-compose.yml file, and copy paste the following:
- Create a file called
.envin the same folder as your docker-compose.yml file and copy paste the following:
you do not need to use a .env and can pass that information directly via the docker-compose file, however I have gotten used to using one to keep sensitive data secure
- Regardless of the method you use to specify a folder for Portainer's
/datamapping, make sure that you create that volume before moving on to the next step
- Back in SSH, navigate to the directory you created your
docker-compose.ymlfile, and run the following command:
note that if you've named your stack, any further commands relating to this stack must also include the
-p "portainer"argument or it will create a new stack
If everything's gone well, you can now enter
http://yourMachine'sIP:9000 in your browser address bar and you will be directed to this screen:
- Create a username (I've called mine 'myuser'), password, confirm the password, then hit 'Create user'
- At the next screen, make sure you select the 'Docker' button before hitting connect
On the next screen, you should see a dashboard-type view, which gives a broad overview of your current docker container numbers, plus some other stats like storage space used etc.
All these options are now available for selection. Going into your 'Containers' section shows you a tabulated list of your containers, including their names, stack names, the images they use, and if set, their (clickable) port numbers for direct access to those services/gui.
You can also use portainer to create containers with docker-compose files. Click into the 'Stacks' tab:
You'll notice that my stacks here show as
Limited under 'Control'. This is because they weren't created using Portainer, rather via SSH. To create a stack via Portainer, click the '+ Add stack' button:
I'm going to recreate my Diun container
Notice that I have variables listed as '$DOCKERDIR' and '$TZ' and '$APPTOKEN' - the compose file will look for this data in a .env file, which Portainer allows you to load from your local machine:
When you're ready, hit 'Deploy the stack'. You should get a green 'stack deployed successfully' notice on the top right corner of the screen, and you'll be redirected back to the 'Stacks' screen, where you should be able to select your new stack:
If you click into it, you'll have the option to modify, stop, start and delete the stack.
Let's go to the 'Containers' page and find the container:
Let's click the container name, and see what it shows us:
There's a lot of info here. At the top we have the actions (start, stop, remove etc.). Under the 'Status' parts, we can see the name (and change it if we want) and runtime. And under that, we have some other tools - 'Logs' and 'Console' are particularly useful.
'Console' allows you to ssh or 'bash' into your container should you have a need to make configurations or settings changes in that way
At the bottom of the page, we have the environment variables, the volumes being used, and the network options:
These network options are very handy for network joining/leaving.
There's a lot more you can do here, whether you use Portainer to create your stacks or not. You can prune (remove) unused images and volumes, create and manage networks, and of course have complete control over containers and stacks created via Portainer's GUI.