Skip to content

Instantly share code, notes, and snippets.

Last active January 18, 2021 14:29
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry swarm-1
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry swarm-2
docker-machine create --driver hyperv --hyperv-virtual-switch ExternalSwitch --engine-insecure-registry 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
docker-machine ssh swarm-3 docker swarm join --token SWMTKN-1-mysecrettoken

& "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:

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

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

Copy link

alexellis commented Sep 27, 2017

That's a very cool example. Would make a good blog post!

Copy link

Very cool!

You can get the IP address with

$ip = $(docker-machine ip registry)

and use it for the next commands. PowerShell of course.

Copy link

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

Copy link

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