How to install Portainer
How to install Portainer
Portainer is a useful GUI tool for interfacing with Docker. It runs as a container stack, and communicates directly with Docker itself.
Portainer particularly shines when managing a Docker Swarm.
Docker Swarm Mode
First, Create a Docker Swarm.
Install and deploy Community Edition
First, download the latest stack file to somewhere on your manager node that will persist between reboots (i.e. DON’T use /tmp, as the file will be autoremoved).
For example:
1
2
3
mkdir -p ~/Projects/portainer
cd ~/Projects/portainer
curl -L https://downloads.portainer.io/ce2-16/portainer-agent-stack.yml -o portainer-agent-stack.yml
Update the stack file to use latest instead of whatever version is current (e.g. 2.16.2).
For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
version: '3.2'
services:
agent:
image: portainer/agent:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:latest
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9443:9443"
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
networks:
agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:
Once you have a stack file, deploy the stack to your swarm from a manager node using:
1
docker stack deploy -c portainer-agent-stack.yml portainer
You should now be able to visit any node in your docker swarm on port 9000 or 9443 (http and https respectively) to open portainer.
