Created
September 5, 2017 11:44
-
-
Save bvis/ee84a5a708a2c96da4cba2c06fbc525d to your computer and use it in GitHub Desktop.
Autoregister your swarm nodes in Portainer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the password needed to login to portainer and reuse it for the portainer endpoints. | |
export VOLUME_DRIVER=local | |
export PORTAINER_PASS=mySuperSECRETPass | |
export PORTAINER_ENC_PASS=$(docker run --rm httpd:2.4-alpine htpasswd -nbB admin ${PORTAINER_PASS} | cut -d ":" -f 2) | |
echo $PORTAINER_PASS | docker secret create portainer_password.v1 --label portainer - | |
# Deploy the stack! | |
docker stack deploy --compose-file docker-compose.yml portainer | |
# In just a few seconds you should have your portainer service with all the cluster nodes auto-registered! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.3" | |
networks: | |
portainer: | |
volumes: | |
portainer: | |
driver: ${VOLUME_DRIVER} | |
services: | |
portainer: | |
image: portainer/portainer | |
networks: | |
- portainer | |
ports: | |
- "9000:9000" | |
volumes: | |
- portainer:/data | |
- /var/run/docker.sock:/var/run/docker.sock | |
command: [ | |
"--admin-password", "${PORTAINER_ENC_PASS}" | |
] | |
deploy: | |
mode: replicated | |
replicas: 1 | |
resources: | |
limits: | |
cpus: '0.20' | |
memory: 30M | |
reservations: | |
cpus: '0.10' | |
memory: 25M | |
portainer-endpoint: | |
image: softonic/portainer-endpoint | |
networks: | |
- portainer | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
- /etc/hostname:/etc/host_hostname | |
environment: | |
HOST_HOSTNAME: "/etc/host_hostname" | |
PORTAINER_ADDR: "portainer:9000" | |
PORTAINER_USER: "admin" | |
PORTAINER_PASS: "--DOCKER-SECRET:portainer_password--" | |
secrets: | |
- source: "portainer_password.v1" | |
target: "portainer_password" | |
uid: "33" | |
gid: "33" | |
mode: 0400 | |
deploy: | |
mode: global | |
resources: | |
limits: | |
cpus: '0.10' | |
memory: 20M | |
reservations: | |
cpus: '0.05' | |
memory: 10M | |
secrets: | |
portainer_password.v1: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment