Initial version of libcontainer API.

Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)

This is an initial proposal of what a libcontainer API would look like. You can see it is in no way implemented :) This is primarily for discussion on the API, we can merge this and start working on the individual pieces one at a time.

The proposed API borrows heavily from lmctfy and libct with some changes to improve on those. Key aspects are:
- Container names as hierarchical path
- Separating Creating a container from Getting a container (the latter gets a reference to a running container)
- Containers as objects we can perform action on.

Any and all comments are welcomed :) I think the documentation on these may be a little lighter than I'd like. I can add more as it is requested.
It depends on how namespaces are shared. If the containers in group want
exclusive namespaces, we'll need cgroups without processes. systemd
supports cgroups with subcgroups, but I think the API for that isn't
straightforward. @alexlarsson would know better if that can be done.


On Wed, Jun 18, 2014 at 4:45 PM, Vish Kannan <notifications@github.com>
wrote:

> In api.go:
>
> > +//    /sys/sub    : the "sub" container inside the "sys" top level container
> > +//    .           : the current container
> > +//    ./          : the current container
> > +//    ..          : the parent of the current container
> > +//    sub         : the "sub" subcontainer (child container) of the current container
> > +//    ./sub       : the "sub" subcontainer (child container) of the current container
> > +//    /sub        : the "sub" top level container
> > +//    ../sibling  : the "sibling" child container of the parent container
> > +//
> > +// Subcontainers are created under the parent containers and inherit any unspecified container properties.
> > +// This means that they are created within the namespaces and cgroups of the parent.
> > +type ContainerFactory interface {
> > +	// Creates a new container with the specified name and properties. If namespaces are specified in the spec,
> > +	// then a containerInit must also be specified. This is the process that will be run as the init in the namespace.
> > +	// On error, the partially created container is destroyed.
> > +	Create(name string, spec *Container, containerInit *ProcessSpec) (*LibcontainerContainer, error)
>
> rjnagal@ if we were to support groups of containers, we will want to have
> cgroups without a process?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/docker/libcontainer/pull/28/files#r13947019>.
>