3. Portainer setup - nerdily/Raspberry-Pi-Docker-Swarm GitHub Wiki
Portainer setup
File permissions
If the correct file permissions aren't set in the persistent volume, Portainer won't be able to function properly. Docker is run by the pi
user so we'll ensure pi can read/write into the persistent volume by changing the group ownership to the pi group.
sudo chown -R root:pi /mnt/glusterfs/portainer
sudo chmod -R 775 /mnt/glusterfs/portainer
sudo chmod g+s /mnt/glusterfs/portainer
(Ensures all future content in the folder will inherit group ownership)
portainer-stack.env
Make sure portainer-stack.env is in the same directory as the portainer.yml file
AGENT_TOKEN=$(openssl rand -base64 16)
portainer.yml
version: '3.4'
services:
agent:
image: portainer/agent:latest
env_file: portainer-stack.env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- portainer_agent
deploy:
mode: global
placement:
constraints:
- "node.platform.os == linux"
manager:
image: portainer/portainer-ce:latest
command: -H tcp://tasks.agent:9001 --tlsskipverify
env_file: portainer-stack.env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
- target: 9000 # for user interface
published: 9000
protocol: tcp
mode: host
- target: 8000 # for EDGE agent
published: 8000
protocol: tcp
mode: host
networks:
- portainer_agent
deploy:
placement:
constraints:
- "node.role == manager"
volumes:
portainer_data:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/glusterfs/portainer/data
networks:
portainer_agent:
driver: overlay
attachable: true
Run Portainer
docker stack deploy --compose-file=/mnt/glusterfs/configs/portainer/portainer.yml portainer
Now, you can do all of your setup and configuration of stacks/containers/networks/etc with Portainer. Or you can do it on the command line. If you start a stack/container etc from the command line, Portainer will not be able to stop/restart it through its UI. You would have to do it at the command line. Otherwise, Portainer has full info on the Swarm.