| Also make sure `avahi-daemon` works, and otherwise restart it. See [this issue](https://github.com/hypriot/image-builder-rpi/issues/170). | Also make sure `avahi-daemon` works, and otherwise restart it. See [this issue](https://github.com/hypriot/image-builder-rpi/issues/170). | ||||
| Swarm | |||||
| ----- | |||||
| Login to the main RPI and start the swarm: | |||||
| docker swarm init --listen-addr eth0 | |||||
| And join from the other ones, just copy-paste command provided by the master from them: | |||||
| docker swarm join --token your-token your-main_rpi:2377 | |||||
| Data and volumes | Data and volumes | ||||
| ---------------- | ---------------- | ||||
| Configuration and deployment | Configuration and deployment | ||||
| ---------------------------- | ---------------------------- | ||||
| ## Swarm mode | |||||
| First download the repos: | |||||
| git clone https://github.com/bingen/rpi_docker_home_server.git | |||||
| cd rpi_docker_home_server | |||||
| Set up your preferences: | |||||
| ./setup.sh | |||||
| (Optional, can be downloaded from registry, unless you changed them) Build aux images: | |||||
| cd images/rpi-nginx | |||||
| docker build . -t bingen/rpi-nginx | |||||
| cd ../../ | |||||
| cd images/rpi-nginx-php | |||||
| docker build . -t bingen/rpi-nginx-php | |||||
| cd ../../ | |||||
| (Optional, can be downloaded from registry, unless you changed them) Build images: | |||||
| docker-compose build | |||||
| Deploy docker stack (it will also rebuild components) | |||||
| ./deploy.sh your-stack-name | |||||
| If you add or modify a service, you can update it running: | |||||
| docker-compose build && docker push your-container && env $(cat .env | grep "^[A-Z]" | xargs) docker stack deploy --compose-file docker-compose.yml your-stack | |||||
| ## No swarm mode | |||||
| If it's a restart, clean first previous containers: | If it's a restart, clean first previous containers: | ||||
| for i in $(docker ps -a | grep Exited | grep dhs | cut -f 1 -d ' '); do docker rm $i; done; | for i in $(docker ps -a | grep Exited | grep dhs | cut -f 1 -d ' '); do docker rm $i; done; | ||||
| Add users: | Add users: | ||||
| ./add_users_noswarm.sh | |||||
| ./add_users.sh | |||||
| Add DNS entries: | Add DNS entries: | ||||
| ./add_dns_entries_noswarm.sh | |||||
| ./add_dns_entries.sh | |||||
| Add Nextcloud apps: | Add Nextcloud apps: | ||||
| ./nextcloud_apps_after_update_noswarm.sh | |||||
| ./nextcloud_apps_after_update.sh | |||||
| If you add or modify a service, you can update it running: | If you add or modify a service, you can update it running: | ||||
| docker-compose build && docker-compose -p dhs up -d <your-service> | docker-compose build && docker-compose -p dhs up -d <your-service> | ||||
| Other useful commands | |||||
| --------------------- | |||||
| docker node ls | |||||
| docker stack ls | |||||
| docker stack ps your-stack-name | |||||
| To see logs of a docker swarm/stack service [reference](https://github.com/docker/docker/issues/23710): | |||||
| docker logs $(docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" `docker stack ps your-stack-name | grep your-service-name | cut -f1 -d' '`) | |||||
| To shutdown the stack: | |||||
| docker stack rm your-stack-name | |||||
| To get into containers: | |||||
| docker ps # in the swarm node containing it | |||||
| docker exec -ti 5105b27d9cf0 bash | |||||
| To view swarm token: | |||||
| docker swarm join-token worker | |||||
| I was experience the issue described and fixed [here](Docker swarm nodes down after reboot! | |||||
| https://forums.docker.com/t/docker-worker-nodes-shown-as-down-after-re-start/22329/8?u=bingen): | |||||
| To avoid swarm nodes showing up as Down on reboot, you can do: | |||||
| sudo crontab -e | |||||
| then add a line like this | |||||
| @reboot docker ps | |||||
| Openldap | Openldap | ||||
| -------- | -------- | ||||