I have a few servers. Each of them has a lot of docker-compose projects for HTTPS Projects which use one auto discovering reverse proxy for HTTPS.
A few days ago I discovered on youtube, that swarm is totally easy to setup and would give me a lot of possibilities to move containers between those maschines without a huge down time.
Now to my two problems:
1.) Syncing configs and letsencrypt certificates
I created a configuration:
version: '3.2' services: nginx: image: myFancyImage networks: - web restart: always deploy: mode: global ports: - target: 80 published: 81 # for testing protocol: tcp mode: ingress - target: 443 published: 444 # for testing protocol: tcp mode: ingress volumes: - mainnginx-www:/var/www - mainnginx-letsencrypt:/etc/letsencrypt - mainnginx-sites-enabled:/etc/nginx/sites-enabled/ volumes: mainnginx-www: mainnginx-letsencrypt: mainnginx-sites-enabled: networks: web: external: name: web1
And deployed the service via:
docker stack deploy --compose-file docker-compose.yml mainnginx
Now on both maschines an instance of my reverse proxy ran and mounted three volumes, but they are only local not shared.
Of course I am able to use NFS to sync them but what is best practice here? NFS looks like unclean. I read somewhere, that docker is mounting from the manager, but this is not what happens...
How did you solve this?
2.) Using a swarm network to work with local containers
I created a network for my mainproxy:
docker network create --opt encrypted --attachable --driver overlay web1
and added one of my local projects from server1 to the network like shown in the presentation.
I then tried to connect from my server1 reverse proxy and from my server2 reverse proxy to ping my projects container and was only able to do this from server1. Server2 discovered the correct IP, but neither pinged nor ponged. It just waited.
What did I do wrong? Was that not the idea in total?