Skip to content
This repository was archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #953 from ehazlett/bump_0.2.0
Browse files Browse the repository at this point in the history
Bump 0.2.0
  • Loading branch information
ehazlett committed Apr 16, 2015
2 parents f6192d1 + f1c04ff commit 8b9eaf2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 14 deletions.
4 changes: 2 additions & 2 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ func generateUsageHint(machineName string, userShell string) string {
}
default:
if machineName != "" {
cmd = fmt.Sprintf("eval $(docker-machine env %s)", machineName)
cmd = fmt.Sprintf("eval \"$(docker-machine env %s)\"", machineName)
} else {
cmd = "eval $(docker-machine env)"
cmd = "eval \"$(docker-machine env)\""
}
}

Expand Down
67 changes: 65 additions & 2 deletions docs/DRIVER_SPEC.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
> DRAFT
# Machine Driver Specification v1
This is the standard configuration and specification for version 1 drivers.

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

Currently Machine requires Ubuntu for non-Boot2Docker machines. This will
change in the future.

## API Access
We prefer accessing the provider service via HTTP APIs and strongly recommend
using those over external executables. For example, using the Amazon EC2 API
Expand Down Expand Up @@ -83,3 +84,65 @@ If you want to use a third party library to interact with the provider, you
will need to make sure it is compliant with the Docker license terms (non-GPL).
For more information, contact a project maintainer.

# Implementation
The following describes what is needed to create a Machine Driver. The driver
interface has methods that must be implemented for all drivers. These include
operations such as `Create`, `Remove`, `Start`, `Stop` etc.

For details see the [Driver Interface](https://github.com/docker/machine/blob/master/drivers/drivers.go#L24).

To provide this functionality, most drivers use a struct similar to the following:

```
type Driver struct {
MachineName string
IPAddress string
SSHUser string
SSHPort int
CaCertPath string
PrivateKeyPath string
DriverKeyPath string
SwarmMaster bool
SwarmHost string
SwarmDiscovery string
storePath string
}
```

Each driver must then use an `init` func to "register" the driver:

```
func init() {
drivers.Register("drivername", &drivers.RegisteredDriver{
New: NewDriver,
GetCreateFlags: GetCreateFlags,
})
}
```

## Flags
Driver flags are used for provider specific customizations. To add flags, use
a `GetCreateFlags` func. For example:

```
func GetCreateFlags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
EnvVar: "DRIVERNAME_TOKEN",
Name: "drivername-token",
Usage: "Provider access token",
},
cli.StringFlag{
EnvVar: "DRIVERNAME_IMAGE",
Name: "drivername-image",
Usage: "Provider Image",
Value: "ubuntu-14-04-x64",
},
}
}
```

## Examples
You can reference the existing [Drivers](https://github.com/docker/machine/tree/master/drivers)
as well.
20 changes: 18 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ managing them:
- Upgrading Docker
- Configuring the Docker client to talk to your host

## Getting help

Docker Machine is still in its infancy and under active development. If you need
help, would like to contribute, or simply want to talk about to the project with
like-minded individuals, we have a number of open channels for communication.

- To report bugs or file feature requests: please use the [issue tracker on
Github](https://github.com/docker/machine/issues).
- To talk about the project with people in real time: please join the
`#docker-machine` channel on IRC.
- To contribute code or documentation changes: please [submit a pull request on
Github](https://github.com/docker/machine/pulls).

For more information and resources, please visit
[https://docs.docker.com/project/get-help/](https://docs.docker.com/project/get-help/).

## Installation

Docker Machine is supported on Windows, OSX, and Linux. To install Docker
Expand Down Expand Up @@ -314,7 +330,7 @@ docker-machine create \
```

You now have a Swarm cluster across two nodes.
To connect to the Swarm master, use `docker-machine env --swarm swarm-master`
To connect to the Swarm master, use `eval $(docker-machine env --swarm swarm-master)`

For example:

Expand Down Expand Up @@ -820,7 +836,7 @@ variable and CLI option are provided the CLI option takes the precedence.
| Environment variable | CLI option |
|----------------------|-----------------------------|
| `OS_USERNAME` | `--rackspace-username` |
| `OS_API_KEY` | `--rackspace-ap-key` |
| `OS_API_KEY` | `--rackspace-api-key` |
| `OS_REGION_NAME` | `--rackspace-region` |
| `OS_ENDPOINT_TYPE` | `--rackspace-endpoint-type` |

Expand Down
6 changes: 0 additions & 6 deletions drivers/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ func (d *Driver) Create() error {
newDroplet.Droplet.ID,
d.IPAddress)

log.Infof("Waiting for SSH...")

if err := ssh.WaitForTCP(fmt.Sprintf("%s:%d", d.IPAddress, 22)); err != nil {
return err
}

return nil
}

Expand Down
21 changes: 21 additions & 0 deletions libmachine/provision/ubuntu.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"fmt"
"os/exec"

log "github.com/Sirupsen/logrus"
"github.com/docker/machine/drivers"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/provision/pkgaction"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/utils"
)

func init() {
Expand Down Expand Up @@ -80,6 +82,21 @@ func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.Pack
return nil
}

func (provisioner *UbuntuProvisioner) dockerDaemonResponding() bool {
cmd, err := provisioner.SSHCommand("sudo docker version")
if err != nil {
log.Warn("Error getting SSH command to check if the daemon is up: %s", err)
return false
}
if err := cmd.Run(); err != nil {
log.Debug("Error checking for daemon up: %s", err)
return false
}

// The daemon is up if the command worked. Carry on.
return true
}

func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions) error {
if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil {
return err
Expand All @@ -95,6 +112,10 @@ func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions,
return err
}

if err := utils.WaitFor(provisioner.dockerDaemonResponding); err != nil {
return err
}

if err := ConfigureAuth(provisioner, authOptions); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
func GetSSHCommand(host string, port int, user string, sshKey string, args ...string) *exec.Cmd {
defaultSSHArgs := []string{
"-o", "IdentitiesOnly=yes",
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no", // don't bother checking in ~/.ssh/known_hosts
"-o", "UserKnownHostsFile=/dev/null", // don't write anything to ~/.ssh/known_hosts
"-o", "ConnectionAttempts=30", // retry 30 times if SSH connection fails
"-o", "LogLevel=quiet", // suppress "Warning: Permanently added '[localhost]:2022' (ECDSA) to the list of known hosts."
"-p", fmt.Sprintf("%d", port),
"-i", sshKey,
Expand Down

0 comments on commit 8b9eaf2

Please sign in to comment.