-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprovision-portainer.sh
45 lines (41 loc) · 1.08 KB
/
provision-portainer.sh
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
40
41
42
43
44
45
#!/bin/bash
set -euxo pipefail
# see https://github.com/portainer/portainer/releases
# see https://hub.docker.com/r/portainer/portainer-ce/tags
portainer_version="${1:-2.11.0}"; shift || true
docker volume create portainer_data
docker run \
-d \
-p 9000:9000 \
--name=portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:$portainer_version
# wait for portainer to be ready.
while [ -z "$(http --ignore-stdin localhost:9000/api/status | jq -r .Version)" ]; do sleep 3; done
# add the docker endpoint.
# see https://documentation.portainer.io/api/
http \
--ignore-stdin \
POST \
localhost:9000/api/users/admin/init \
Username=admin \
Password=abracadabra \
>/dev/null
authentication_token="$(http \
--ignore-stdin \
POST \
localhost:9000/api/auth \
Username=admin \
Password=abracadabra \
| jq -r .jwt)"
http \
--ignore-stdin \
--form \
POST \
localhost:9000/api/endpoints \
"Authorization: Bearer $authentication_token" \
Name=docker \
EndpointCreationType=1 \
>/dev/null