Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions libcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ func init() {
if len(os.Args) > 1 && os.Args[1] == "init" {
runtime.GOMAXPROCS(1)
runtime.LockOSThread()
if err := libcontainer.StartInitialization(); err != nil {
factory, _ := libcontainer.New("")
if err := factory.StartInitialization(); err != nil {
logrus.Fatal(err)
}
panic("--this line should have never been executed, congratulations--")
}
}
```

To create a container you first have to initialize an instance of a factory
that will handle the creation and initialization for a container.

```go
factory, err := libcontainer.New("/var/lib/container", libcontainer.Cgroupfs, libcontainer.InitArgs(os.Args[0], "init"))
if err != nil {
logrus.Fatal(err)
return
}
```

Then to create a container you first have to create a configuration
struct describing how the container is to be created. A sample would look similar to this:

Expand Down Expand Up @@ -215,11 +227,10 @@ config := &configs.Config{
}
```

Once you have the configuration populated you can create a container
with a specified ID under a specified state directory:
Once you have the configuration populated you can create a container:

```go
container, err := libcontainer.Create("/run/containers", "container-id", config)
container, err := factory.Create("container-id", config)
if err != nil {
logrus.Fatal(err)
return
Expand Down