@@ -14,6 +14,10 @@ import (
1414 "github.com/docker/machine/ssh"
1515)
1616
17+ const (
18+ dockerConfigDir = "/etc/docker"
19+ )
20+
1721// Driver is a struct compatible with the docker.hosts.drivers.Driver interface.
1822type Driver struct {
1923 MachineName string
@@ -22,6 +26,8 @@ type Driver struct {
2226 storePath string
2327 UserName string
2428 Project string
29+ CaCertPath string
30+ PrivateKeyPath string
2531 sshKeyPath string
2632 publicSSHKeyPath string
2733}
@@ -72,10 +78,12 @@ func GetCreateFlags() []cli.Flag {
7278}
7379
7480// NewDriver creates a Driver with the specified storePath.
75- func NewDriver (machineName string , storePath string ) (drivers.Driver , error ) {
81+ func NewDriver (machineName string , storePath string , caCert string , privateKey string ) (drivers.Driver , error ) {
7682 return & Driver {
7783 MachineName : machineName ,
7884 storePath : storePath ,
85+ CaCertPath : caCert ,
86+ PrivateKeyPath : privateKey ,
7987 sshKeyPath : path .Join (storePath , "id_rsa" ),
8088 publicSSHKeyPath : path .Join (storePath , "id_rsa.pub" ),
8189 }, nil
@@ -225,6 +233,38 @@ func (driver *Driver) Kill() error {
225233 return driver .Stop ()
226234}
227235
236+ func (d * Driver ) StartDocker () error {
237+ log .Debug ("Starting Docker..." )
238+
239+ cmd , err := d .GetSSHCommand ("sudo service docker start" )
240+ if err != nil {
241+ return err
242+ }
243+ if err := cmd .Run (); err != nil {
244+ return err
245+ }
246+
247+ return nil
248+ }
249+
250+ func (d * Driver ) StopDocker () error {
251+ log .Debug ("Stopping Docker..." )
252+
253+ cmd , err := d .GetSSHCommand ("sudo service docker stop" )
254+ if err != nil {
255+ return err
256+ }
257+ if err := cmd .Run (); err != nil {
258+ return err
259+ }
260+
261+ return nil
262+ }
263+
264+ func (d * Driver ) GetDockerConfigDir () string {
265+ return dockerConfigDir
266+ }
267+
228268// GetSSHCommand returns a command that will run over SSH on the GCE instance.
229269func (driver * Driver ) GetSSHCommand (args ... string ) (* exec.Cmd , error ) {
230270 ip , err := driver .GetIP ()
0 commit comments