Skip to content

Instantly share code, notes, and snippets.

@johnmccabe
Last active January 18, 2021 14:29
Show Gist options
  • Save johnmccabe/55baab605c0fb82df9c1cbf8c3dde407 to your computer and use it in GitHub Desktop.
Save johnmccabe/55baab605c0fb82df9c1cbf8c3dde407 to your computer and use it in GitHub Desktop.
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

@StefanScherer
Copy link

So docker-machine works in parallel to Docker4Windows?
I tried that recently, but had errors with the NAT network.

@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