It includes new Type() method for Factory, which needed for replacing
execdriver.Driver.
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
| ... | ... |
@@ -68,7 +68,7 @@ if [ "$1" = '--go' ]; then |
| 68 | 68 |
mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar |
| 69 | 69 |
fi |
| 70 | 70 |
|
| 71 |
-clone git github.com/docker/libcontainer aa10040b570386c1ae311c6245b9e21295b2b83a |
|
| 71 |
+clone git github.com/docker/libcontainer 5d6c507d7cfeff97172deedf3db13b5295bcacef |
|
| 72 | 72 |
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file) |
| 73 | 73 |
rm -rf src/github.com/docker/libcontainer/vendor |
| 74 | 74 |
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 |
| 7 | 7 |
|
| 8 | 8 |
# setup a playground for us to spawn containers in |
| 9 | 9 |
RUN mkdir /busybox && \ |
| 10 |
- curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.02/rootfs.tar' | tar -xC /busybox |
|
| 10 |
+ curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -xC /busybox |
|
| 11 | 11 |
|
| 12 | 12 |
RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/project/dind -o /dind && \ |
| 13 | 13 |
chmod +x /dind |
| ... | ... |
@@ -42,6 +42,12 @@ type Network struct {
|
| 42 | 42 |
// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the |
| 43 | 43 |
// container. |
| 44 | 44 |
HostInterfaceName string `json:"host_interface_name"` |
| 45 |
+ |
|
| 46 |
+ // HairpinMode specifies if hairpin NAT should be enabled on the virtual interface |
|
| 47 |
+ // bridge port in the case of type veth |
|
| 48 |
+ // Note: This is unsupported on some systems. |
|
| 49 |
+ // Note: This does not apply to loopback interfaces. |
|
| 50 |
+ HairpinMode bool `json:"hairpin_mode"` |
|
| 45 | 51 |
} |
| 46 | 52 |
|
| 47 | 53 |
// Routes can be specified to create entries in the route table as the container is started |
| ... | ... |
@@ -172,6 +172,10 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
|
| 172 | 172 |
}, nil |
| 173 | 173 |
} |
| 174 | 174 |
|
| 175 |
+func (l *LinuxFactory) Type() string {
|
|
| 176 |
+ return "libcontainer" |
|
| 177 |
+} |
|
| 178 |
+ |
|
| 175 | 179 |
// StartInitialization loads a container by opening the pipe fd from the parent to read the configuration and state |
| 176 | 180 |
// This is a low level implementation detail of the reexec and should not be consumed externally |
| 177 | 181 |
func (l *LinuxFactory) StartInitialization(pipefd uintptr) (err error) {
|
| ... | ... |
@@ -43,6 +43,10 @@ func TestFactoryNew(t *testing.T) {
|
| 43 | 43 |
if lfactory.Root != root {
|
| 44 | 44 |
t.Fatalf("expected factory root to be %q but received %q", root, lfactory.Root)
|
| 45 | 45 |
} |
| 46 |
+ |
|
| 47 |
+ if factory.Type() != "libcontainer" {
|
|
| 48 |
+ t.Fatalf("unexpected factory type: %q, expected %q", factory.Type(), "libcontainer")
|
|
| 49 |
+ } |
|
| 46 | 50 |
} |
| 47 | 51 |
|
| 48 | 52 |
func TestFactoryLoadNotExists(t *testing.T) {
|
| ... | ... |
@@ -135,6 +135,11 @@ func (v *veth) create(n *network, nspid int) (err error) {
|
| 135 | 135 |
if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
|
| 136 | 136 |
return err |
| 137 | 137 |
} |
| 138 |
+ if n.HairpinMode {
|
|
| 139 |
+ if err := netlink.SetHairpinMode(host, true); err != nil {
|
|
| 140 |
+ return err |
|
| 141 |
+ } |
|
| 142 |
+ } |
|
| 138 | 143 |
if err := netlink.NetworkLinkUp(host); err != nil {
|
| 139 | 144 |
return err |
| 140 | 145 |
} |
| ... | ... |
@@ -24,8 +24,7 @@ var execCommand = cli.Command{
|
| 24 | 24 |
Flags: append([]cli.Flag{
|
| 25 | 25 |
cli.BoolFlag{Name: "tty,t", Usage: "allocate a TTY to the container"},
|
| 26 | 26 |
cli.StringFlag{Name: "id", Value: "nsinit", Usage: "specify the ID for a container"},
|
| 27 |
- cli.StringFlag{Name: "config", Value: "container.json", Usage: "path to the configuration file"},
|
|
| 28 |
- cli.BoolFlag{Name: "create", Usage: "create the container's configuration on the fly with arguments"},
|
|
| 27 |
+ cli.StringFlag{Name: "config", Value: "", Usage: "path to the configuration file"},
|
|
| 29 | 28 |
cli.StringFlag{Name: "user,u", Value: "root", Usage: "set the user, uid, and/or gid for the process"},
|
| 30 | 29 |
cli.StringFlag{Name: "cwd", Value: "", Usage: "set the current working dir"},
|
| 31 | 30 |
cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"},
|
| ... | ... |
@@ -14,7 +14,7 @@ func main() {
|
| 14 | 14 |
app.Author = "libcontainer maintainers" |
| 15 | 15 |
app.Flags = []cli.Flag{
|
| 16 | 16 |
cli.StringFlag{Name: "root", Value: ".", Usage: "root directory for containers"},
|
| 17 |
- cli.StringFlag{Name: "log-file", Value: "nsinit-debug.log", Usage: "set the log file to output logs to"},
|
|
| 17 |
+ cli.StringFlag{Name: "log-file", Value: "", Usage: "set the log file to output logs to"},
|
|
| 18 | 18 |
cli.BoolFlag{Name: "debug", Usage: "enable debug output in the logs"},
|
| 19 | 19 |
} |
| 20 | 20 |
app.Commands = []cli.Command{
|
| ... | ... |
@@ -11,20 +11,20 @@ import ( |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func loadConfig(context *cli.Context) (*configs.Config, error) {
|
| 14 |
- if context.Bool("create") {
|
|
| 15 |
- config := getTemplate() |
|
| 16 |
- modify(config, context) |
|
| 14 |
+ if path := context.String("config"); path != "" {
|
|
| 15 |
+ f, err := os.Open(path) |
|
| 16 |
+ if err != nil {
|
|
| 17 |
+ return nil, err |
|
| 18 |
+ } |
|
| 19 |
+ defer f.Close() |
|
| 20 |
+ var config *configs.Config |
|
| 21 |
+ if err := json.NewDecoder(f).Decode(&config); err != nil {
|
|
| 22 |
+ return nil, err |
|
| 23 |
+ } |
|
| 17 | 24 |
return config, nil |
| 18 | 25 |
} |
| 19 |
- f, err := os.Open(context.String("config"))
|
|
| 20 |
- if err != nil {
|
|
| 21 |
- return nil, err |
|
| 22 |
- } |
|
| 23 |
- defer f.Close() |
|
| 24 |
- var config *configs.Config |
|
| 25 |
- if err := json.NewDecoder(f).Decode(&config); err != nil {
|
|
| 26 |
- return nil, err |
|
| 27 |
- } |
|
| 26 |
+ config := getTemplate() |
|
| 27 |
+ modify(config, context) |
|
| 28 | 28 |
return config, nil |
| 29 | 29 |
} |
| 30 | 30 |
|
| ... | ... |
@@ -100,7 +100,23 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
|
| 100 | 100 |
return err |
| 101 | 101 |
} |
| 102 | 102 |
return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), "") |
| 103 |
- case "tmpfs", "mqueue", "devpts", "sysfs": |
|
| 103 |
+ case "tmpfs": |
|
| 104 |
+ stat, err := os.Stat(dest) |
|
| 105 |
+ if err != nil {
|
|
| 106 |
+ if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
|
|
| 107 |
+ return err |
|
| 108 |
+ } |
|
| 109 |
+ } |
|
| 110 |
+ if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil {
|
|
| 111 |
+ return err |
|
| 112 |
+ } |
|
| 113 |
+ if stat != nil {
|
|
| 114 |
+ if err = os.Chmod(dest, stat.Mode()); err != nil {
|
|
| 115 |
+ return err |
|
| 116 |
+ } |
|
| 117 |
+ } |
|
| 118 |
+ return nil |
|
| 119 |
+ case "mqueue", "devpts", "sysfs": |
|
| 104 | 120 |
if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
|
| 105 | 121 |
return err |
| 106 | 122 |
} |
| ... | ... |
@@ -43,7 +43,7 @@ clone() {
|
| 43 | 43 |
clone git github.com/codegangsta/cli 1.1.0 |
| 44 | 44 |
clone git github.com/coreos/go-systemd v2 |
| 45 | 45 |
clone git github.com/godbus/dbus v2 |
| 46 |
-clone git github.com/Sirupsen/logrus v0.6.0 |
|
| 46 |
+clone git github.com/Sirupsen/logrus v0.6.6 |
|
| 47 | 47 |
clone git github.com/syndtr/gocapability e55e583369 |
| 48 | 48 |
|
| 49 | 49 |
# intentionally not vendoring Docker itself... that'd be a circle :) |