import ( "github.com/docker/machine/drivers" "github.com/docker/machine/libmachine/provision" ) func main() { driverOpts := &drivers.DriverOptions{ Username: "myuser", Password: "mypassword", SSHKeyPath: "/path/to/ssh/key", SwarmOptions: &provision.SwarmOptions{ Replicas: 3, Strategy: "spread", }, } driver := drivers.GetDriver("virtualbox", "myvm", "") driver.SetConfigFromFlags(driverOpts) driver.Create() }
import ( "github.com/docker/machine/drivers/amazonec2" ) func main() { driverOpts := &amazonec2.DriverOptions{ AccessKey: "myaccesskey", SecretKey: "mysecretkey", SecurityGroup: "mysecuritygroup", InstanceType: "t2.micro", Region: "us-west-2", } driver := amazonec2.NewDriver("myvm", "") driver.SetConfigFromFlags(driverOpts) driver.Create() }This example shows how to create a new virtual machine using the AmazonEC2 driver with some driver options. It sets the access key, secret key, security group, instance type, and region.