Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 48bea37

Browse files
committed
Merge remote-tracking branch 'origin/master' into bump_0.2.0
2 parents 10c390f + be9113a commit 48bea37

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

docs/DRIVER_SPEC.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
> DRAFT
2-
31
# Machine Driver Specification v1
42
This is the standard configuration and specification for version 1 drivers.
53

@@ -13,6 +11,9 @@ for Docker Machine.
1311
## Base Operating System
1412
The provider must offer a base operating system supported by the Docker Engine.
1513

14+
Currently Machine requires Ubuntu for non-Boot2Docker machines. This will
15+
change in the future.
16+
1617
## API Access
1718
We prefer accessing the provider service via HTTP APIs and strongly recommend
1819
using those over external executables. For example, using the Amazon EC2 API
@@ -83,3 +84,65 @@ If you want to use a third party library to interact with the provider, you
8384
will need to make sure it is compliant with the Docker license terms (non-GPL).
8485
For more information, contact a project maintainer.
8586

87+
# Implementation
88+
The following describes what is needed to create a Machine Driver. The driver
89+
interface has methods that must be implemented for all drivers. These include
90+
operations such as `Create`, `Remove`, `Start`, `Stop` etc.
91+
92+
For details see the [Driver Interface](https://github.com/docker/machine/blob/master/drivers/drivers.go#L24).
93+
94+
To provide this functionality, most drivers use a struct similar to the following:
95+
96+
```
97+
type Driver struct {
98+
MachineName string
99+
IPAddress string
100+
SSHUser string
101+
SSHPort int
102+
CaCertPath string
103+
PrivateKeyPath string
104+
DriverKeyPath string
105+
SwarmMaster bool
106+
SwarmHost string
107+
SwarmDiscovery string
108+
storePath string
109+
}
110+
```
111+
112+
Each driver must then use an `init` func to "register" the driver:
113+
114+
```
115+
func init() {
116+
drivers.Register("drivername", &drivers.RegisteredDriver{
117+
New: NewDriver,
118+
GetCreateFlags: GetCreateFlags,
119+
})
120+
}
121+
```
122+
123+
## Flags
124+
Driver flags are used for provider specific customizations. To add flags, use
125+
a `GetCreateFlags` func. For example:
126+
127+
```
128+
func GetCreateFlags() []cli.Flag {
129+
return []cli.Flag{
130+
cli.StringFlag{
131+
EnvVar: "DRIVERNAME_TOKEN",
132+
Name: "drivername-token",
133+
Usage: "Provider access token",
134+
135+
},
136+
cli.StringFlag{
137+
EnvVar: "DRIVERNAME_IMAGE",
138+
Name: "drivername-image",
139+
Usage: "Provider Image",
140+
Value: "ubuntu-14-04-x64",
141+
},
142+
}
143+
}
144+
```
145+
146+
## Examples
147+
You can reference the existing [Drivers](https://github.com/docker/machine/tree/master/drivers)
148+
as well.

0 commit comments

Comments
 (0)