Created
April 19, 2016 01:17
-
-
Save sethdmoore/bf4d6e332ec1418c567ddfc9294bd9c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"gopkg.in/lxc/go-lxc.v2" | |
) | |
func main() { | |
lxcpath := lxc.DefaultConfigPath() | |
name := "foo" | |
c, err := lxc.NewContainer(name, lxcpath) | |
if err != nil { | |
fmt.Printf("Could not init container: %s\n", err.Error()) | |
} | |
options := lxc.TemplateOptions{ | |
Template: "/usr/share/lxc/templates/lxc-alpine", | |
} | |
if err := c.Create(options); err != nil { | |
fmt.Printf("Could not create container: %s\n", err.Error()) | |
} | |
output, err := c.Execute("/bin/ls", "/") | |
// will always fail here with "container already defined" | |
if err != nil { | |
fmt.Printf("%s\n", err.Error()) | |
} else { | |
fmt.Printf("%s\n", output) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment