Instantly share code, notes, and snippets.

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

@alexellis

This comment has been minimized.

Show comment
Hide comment
@alexellis

alexellis Sep 27, 2017

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

alexellis commented Sep 27, 2017

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

@StefanScherer

This comment has been minimized.

Show comment
Hide comment
@StefanScherer

StefanScherer Sep 27, 2017

Very cool!

You can get the IP address with

$ip = $(docker-machine ip registry)

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

StefanScherer commented Sep 27, 2017

Very cool!

You can get the IP address with

$ip = $(docker-machine ip registry)

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

@StefanScherer

This comment has been minimized.

Show comment
Hide comment
@StefanScherer

StefanScherer Sep 27, 2017

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

StefanScherer commented Sep 27, 2017

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

@johnmccabe

This comment has been minimized.

Show comment
Hide comment
@johnmccabe

johnmccabe 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.

Owner

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