Skip to content

Commit

Permalink
run/runc: Attach the container to the bridge using a hook
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
  • Loading branch information
nderjung committed Dec 30, 2020
1 parent 5cc9894 commit 764ba23
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions run/runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

"golang.org/x/sys/unix"
"github.com/opencontainers/runc/libcontainer"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runc/libcontainer/specconv"
"github.com/opencontainers/runc/libcontainer/configs"

Expand Down Expand Up @@ -270,6 +271,20 @@ func (r *RuncRunner) Init(in *[]Input, out *[]Output, dryRun bool) error {
Soft: uint64(1025),
},
},
Hooks: configs.Hooks{
configs.Prestart: configs.HookList{
configs.NewFunctionHook(func(s *specs.State) error {
ip, err := r.Bridge.Create(s)
if err != nil {
return err
}

r.log.Debugf("Container IP: %s\n", ip)

return nil
}),
},
},
}

r.container, err = factory.Create(r.log.Prefix, config)
Expand Down

0 comments on commit 764ba23

Please sign in to comment.