Late to the party or not, I have been using containers in my lab more and more and that has led me to Portainer….
I use it for managing the docker containers on my Synology but it can also be used for managing lots of other things. In their own words “Portainer accelerates container adoption. It reduces operational complexity and addresses the security challenges of running containers in Docker, Swarm, Nomad and Kubernetes.”
Based on the capabilities shown above I am only scratching the surface but I thought I would showcase one of the key features that I am utilising in deployment and updating containers.
For now, I am going to assume that you have a Synology, Docker Installed and Portainer deployed. Plus have Github (or similar) version control system that Portainer can reach. If you don’t have this check out Marius’s great blog with detailed instructions for Docker and Portainer It’s also important to understand user and user id’s and a great blog on this can be found here
To deploy a container with Portainer I prefer to deploy them in Stacks even if it’s a single container.
Navigate to the Stacks section and select “Add Stack”
I will show the deployment of a stack to run Grafana as it’s a simple container and popular with homelabbers. The first step is to name the stack which I have called grafana – note these must be lowercase.
The YAML code that the container will use is shown below. This is stored in my private docker repository located at https://github.com/jameskilbynet/docker/grafana
version: '3.3' services: grafana: container_name: grafana image: grafana/grafana user: "1024" ports: - "3000:3000" volumes: - /volume1/docker/grafana:/var/lib/grafana
Reviewing the YAML code it’s clear that volume mapping is being used. This is a feature to expose a file or folder of the underlying Docker Host into the container. In this case /volume1/docker/grafana Therefore this folder must be created manually. Docker will then map this folder into var/lib/grafana within the container to the /volume1/docker/grafana folder on my Synology
Within Portainer to use a git repository change to the Git tab and enter the relevant details.
I am using a private repository and therefore need to enable authentication to allow Portainer to access the private repo. This requires a Personal Access Token to be created as documented here.
When all of the relevent settings are input then click “Deploy the Stack”
Portainer will then instruct docker to fetch the container (if it hasn’t already) and deploy the stack.
If for any reason this errors this is usually as the volume map is not set up correctly or a permissions issue. If it’s the former the docker app in Synology will show you.