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

Commit

Permalink
Install community repo if docker is not found in installed repos
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schmidt <[email protected]>
  • Loading branch information
publicarray committed Jul 5, 2018
1 parent 2ca6cc5 commit 09a83ce
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libmachine/provision/alpine.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (provisioner *AlpineProvisioner) dockerDaemonResponding() bool {
return true
}

func (provisioner *AlpineProvisioner) Service(name string, action serviceaction.ServiceAction) error {
func (provisioner *AlpineProvisioner) Service(name string, action serviceaction.ServiceAction) error {
var command string
switch action {
case serviceaction.Start, serviceaction.Restart, serviceaction.Stop:
Expand All @@ -98,7 +98,7 @@ func (provisioner *AlpineProvisioner) Service(name string, action serviceaction.
case serviceaction.Disable:
command = fmt.Sprintf("sudo rc-update del %s boot", name)
}

if _, err := provisioner.SSHCommand(command); err != nil {
return err
}
Expand Down Expand Up @@ -136,6 +136,11 @@ func (provisioner *AlpineProvisioner) Provision(swarmOptions swarm.Options, auth
}
}

log.Debug("Add Community repo")
if _, err := provisioner.SSHCommand("if ! apk info docker >/dev/null; then ver=$(awk '{split($1,a,\".\"); print a[1]\".\"a[2]}' /etc/alpine-release); echo \"http://dl-cdn.alpinelinux.org/alpine/v$ver/community\" >> /etc/apk/repositories; apk update; fi"); err != nil {
return err
}

log.Debug("Installing docker")
if err := provisioner.Package("docker", pkgaction.Install); err != nil {
return err
Expand Down Expand Up @@ -170,4 +175,4 @@ func (provisioner *AlpineProvisioner) Provision(swarmOptions swarm.Options, auth
}

return nil
}
}

0 comments on commit 09a83ce

Please sign in to comment.