mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Merge pull request #11378 from LK4D4/update_libcontainer
Update libcontainer to 5d6c507d7cfeff97172deedf3db13b5295bcacef
This commit is contained in:
		
						commit
						a97fbe7d78
					
				
					 12 changed files with 56 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -68,7 +68,7 @@ if [ "$1" = '--go' ]; then
 | 
			
		|||
	mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
clone git github.com/docker/libcontainer aa10040b570386c1ae311c6245b9e21295b2b83a
 | 
			
		||||
clone git github.com/docker/libcontainer 5d6c507d7cfeff97172deedf3db13b5295bcacef
 | 
			
		||||
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
 | 
			
		||||
rm -rf src/github.com/docker/libcontainer/vendor
 | 
			
		||||
eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli' | grep -v 'github.com/Sirupsen/logrus')"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ RUN go get github.com/docker/docker/pkg/term
 | 
			
		|||
 | 
			
		||||
# setup a playground for us to spawn containers in
 | 
			
		||||
RUN mkdir /busybox && \
 | 
			
		||||
    curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.02/rootfs.tar' | tar -xC /busybox
 | 
			
		||||
    curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -xC /busybox
 | 
			
		||||
 | 
			
		||||
RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/project/dind -o /dind && \
 | 
			
		||||
    chmod +x /dind
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,6 +42,12 @@ type Network struct {
 | 
			
		|||
	// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
 | 
			
		||||
	// container.
 | 
			
		||||
	HostInterfaceName string `json:"host_interface_name"`
 | 
			
		||||
 | 
			
		||||
	// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
 | 
			
		||||
	// bridge port in the case of type veth
 | 
			
		||||
	// Note: This is unsupported on some systems.
 | 
			
		||||
	// Note: This does not apply to loopback interfaces.
 | 
			
		||||
	HairpinMode bool `json:"hairpin_mode"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Routes can be specified to create entries in the route table as the container is started
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,4 +41,7 @@ type Factory interface {
 | 
			
		|||
	// pipe connection error
 | 
			
		||||
	// system error
 | 
			
		||||
	StartInitialization(pipefd uintptr) error
 | 
			
		||||
 | 
			
		||||
	// Type returns info string about factory type (e.g. lxc, libcontainer...)
 | 
			
		||||
	Type() string
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -172,6 +172,10 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
 | 
			
		|||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (l *LinuxFactory) Type() string {
 | 
			
		||||
	return "libcontainer"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StartInitialization loads a container by opening the pipe fd from the parent to read the configuration and state
 | 
			
		||||
// This is a low level implementation detail of the reexec and should not be consumed externally
 | 
			
		||||
func (l *LinuxFactory) StartInitialization(pipefd uintptr) (err error) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,10 @@ func TestFactoryNew(t *testing.T) {
 | 
			
		|||
	if lfactory.Root != root {
 | 
			
		||||
		t.Fatalf("expected factory root to be %q but received %q", root, lfactory.Root)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if factory.Type() != "libcontainer" {
 | 
			
		||||
		t.Fatalf("unexpected factory type: %q, expected %q", factory.Type(), "libcontainer")
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestFactoryLoadNotExists(t *testing.T) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -135,6 +135,11 @@ func (v *veth) create(n *network, nspid int) (err error) {
 | 
			
		|||
	if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if n.HairpinMode {
 | 
			
		||||
		if err := netlink.SetHairpinMode(host, true); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if err := netlink.NetworkLinkUp(host); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,8 +24,7 @@ var execCommand = cli.Command{
 | 
			
		|||
	Flags: append([]cli.Flag{
 | 
			
		||||
		cli.BoolFlag{Name: "tty,t", Usage: "allocate a TTY to the container"},
 | 
			
		||||
		cli.StringFlag{Name: "id", Value: "nsinit", Usage: "specify the ID for a container"},
 | 
			
		||||
		cli.StringFlag{Name: "config", Value: "container.json", Usage: "path to the configuration file"},
 | 
			
		||||
		cli.BoolFlag{Name: "create", Usage: "create the container's configuration on the fly with arguments"},
 | 
			
		||||
		cli.StringFlag{Name: "config", Value: "", Usage: "path to the configuration file"},
 | 
			
		||||
		cli.StringFlag{Name: "user,u", Value: "root", Usage: "set the user, uid, and/or gid for the process"},
 | 
			
		||||
		cli.StringFlag{Name: "cwd", Value: "", Usage: "set the current working dir"},
 | 
			
		||||
		cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@ func main() {
 | 
			
		|||
	app.Author = "libcontainer maintainers"
 | 
			
		||||
	app.Flags = []cli.Flag{
 | 
			
		||||
		cli.StringFlag{Name: "root", Value: ".", Usage: "root directory for containers"},
 | 
			
		||||
		cli.StringFlag{Name: "log-file", Value: "nsinit-debug.log", Usage: "set the log file to output logs to"},
 | 
			
		||||
		cli.StringFlag{Name: "log-file", Value: "", Usage: "set the log file to output logs to"},
 | 
			
		||||
		cli.BoolFlag{Name: "debug", Usage: "enable debug output in the logs"},
 | 
			
		||||
	}
 | 
			
		||||
	app.Commands = []cli.Command{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,20 +11,20 @@ import (
 | 
			
		|||
)
 | 
			
		||||
 | 
			
		||||
func loadConfig(context *cli.Context) (*configs.Config, error) {
 | 
			
		||||
	if context.Bool("create") {
 | 
			
		||||
		config := getTemplate()
 | 
			
		||||
		modify(config, context)
 | 
			
		||||
	if path := context.String("config"); path != "" {
 | 
			
		||||
		f, err := os.Open(path)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		defer f.Close()
 | 
			
		||||
		var config *configs.Config
 | 
			
		||||
		if err := json.NewDecoder(f).Decode(&config); err != nil {
 | 
			
		||||
			return nil, err
 | 
			
		||||
		}
 | 
			
		||||
		return config, nil
 | 
			
		||||
	}
 | 
			
		||||
	f, err := os.Open(context.String("config"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	defer f.Close()
 | 
			
		||||
	var config *configs.Config
 | 
			
		||||
	if err := json.NewDecoder(f).Decode(&config); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	config := getTemplate()
 | 
			
		||||
	modify(config, context)
 | 
			
		||||
	return config, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,7 +100,23 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
 | 
			
		|||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), "")
 | 
			
		||||
	case "tmpfs", "mqueue", "devpts", "sysfs":
 | 
			
		||||
	case "tmpfs":
 | 
			
		||||
		stat, err := os.Stat(dest)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
		if stat != nil {
 | 
			
		||||
			if err = os.Chmod(dest, stat.Mode()); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return nil
 | 
			
		||||
	case "mqueue", "devpts", "sysfs":
 | 
			
		||||
		if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ clone() {
 | 
			
		|||
clone git github.com/codegangsta/cli 1.1.0
 | 
			
		||||
clone git github.com/coreos/go-systemd v2
 | 
			
		||||
clone git github.com/godbus/dbus v2
 | 
			
		||||
clone git github.com/Sirupsen/logrus v0.6.0
 | 
			
		||||
clone git github.com/Sirupsen/logrus v0.6.6
 | 
			
		||||
clone git github.com/syndtr/gocapability e55e583369
 | 
			
		||||
 | 
			
		||||
# intentionally not vendoring Docker itself...  that'd be a circle :)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue