Skip to content

Instantly share code, notes, and snippets.

@johnmccabe
Last active Jan 18, 2021
Embed
What would you like to do?
Running OpenFaaS on Windows 10 - using Docker Swarm on Hyper-V
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch registry
docker-machine ssh registry docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker-machine ls # get the ip address of the VM, in this case 10.10.10.197
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry 10.10.10.197:5000 swarm-1
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry 10.10.10.197:5000 swarm-2
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry 10.10.10.197:5000 swarm-3
docker-machine ssh swarm-1 docker swarm init  # copy the swarm join command to run on each other hose
docker-machine ssh swarm-2 docker swarm join --token SWMTKN-1-mysecrettoken 10.10.10.198:2377
docker-machine ssh swarm-3 docker swarm join --token SWMTKN-1-mysecrettoken 10.10.10.198:2377

& "C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe" env swarm-1 | Invoke-Expression

In your functions set the function name so that it begins with the address of the registry, for example:

provider:
  name: faas
  gateway: http://10.10.10.198:8080  # use the IP address of the host swarm-1
  network: "func_functions"       # this is optional and defaults to func_functions

  ruby-echo:
    lang: ruby
    handler: ./sample/ruby-echo
    image: 10.10.10.197:5000/ruby-echo # use the IP of the local registry

@johnmccabe
Copy link
Author

johnmccabe commented Sep 27, 2017

I've not noticed any errors @StefanScherer, I was actually running OpenFaaS on the swarm, and connecting to it from Portainer running in the regular Docker instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment