Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 07b3aac9020f1f5e3f7af0cb691cfb6e2189c089)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -26,9 +26,10 @@ var keySize = []byte("size")
|
| 26 | 26 |
|
| 27 | 27 |
// Opt defines options for creating the snapshotter |
| 28 | 28 |
type Opt struct {
|
| 29 |
- GraphDriver graphdriver.Driver |
|
| 30 |
- LayerStore layer.Store |
|
| 31 |
- Root string |
|
| 29 |
+ GraphDriver graphdriver.Driver |
|
| 30 |
+ LayerStore layer.Store |
|
| 31 |
+ Root string |
|
| 32 |
+ IdentityMapping *idtools.IdentityMapping |
|
| 32 | 33 |
} |
| 33 | 34 |
|
| 34 | 35 |
type graphIDRegistrar interface {
|
| ... | ... |
@@ -79,7 +80,7 @@ func (s *snapshotter) Name() string {
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
func (s *snapshotter) IdentityMapping() *idtools.IdentityMapping {
|
| 82 |
- return nil |
|
| 82 |
+ return s.opt.IdentityMapping |
|
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
func (s *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...snapshots.Opt) error {
|
| ... | ... |
@@ -253,6 +254,7 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) (snapshot.Mountabl |
| 253 | 253 |
id := identity.NewID() |
| 254 | 254 |
var rwlayer layer.RWLayer |
| 255 | 255 |
return &mountable{
|
| 256 |
+ idmap: s.opt.IdentityMapping, |
|
| 256 | 257 |
acquire: func() ([]mount.Mount, error) {
|
| 257 | 258 |
rwlayer, err = s.opt.LayerStore.CreateRWLayer(id, l.ChainID(), nil) |
| 258 | 259 |
if err != nil {
|
| ... | ... |
@@ -278,6 +280,7 @@ func (s *snapshotter) Mounts(ctx context.Context, key string) (snapshot.Mountabl |
| 278 | 278 |
id, _ := s.getGraphDriverID(key) |
| 279 | 279 |
|
| 280 | 280 |
return &mountable{
|
| 281 |
+ idmap: s.opt.IdentityMapping, |
|
| 281 | 282 |
acquire: func() ([]mount.Mount, error) {
|
| 282 | 283 |
rootfs, err := s.opt.GraphDriver.Get(id, "") |
| 283 | 284 |
if err != nil {
|
| ... | ... |
@@ -440,6 +443,7 @@ type mountable struct {
|
| 440 | 440 |
acquire func() ([]mount.Mount, error) |
| 441 | 441 |
release func() error |
| 442 | 442 |
refCount int |
| 443 |
+ idmap *idtools.IdentityMapping |
|
| 443 | 444 |
} |
| 444 | 445 |
|
| 445 | 446 |
func (m *mountable) Mount() ([]mount.Mount, error) {
|
| ... | ... |
@@ -480,5 +484,5 @@ func (m *mountable) Release() error {
|
| 480 | 480 |
} |
| 481 | 481 |
|
| 482 | 482 |
func (m *mountable) IdentityMapping() *idtools.IdentityMapping {
|
| 483 |
- return nil |
|
| 483 |
+ return m.idmap |
|
| 484 | 484 |
} |
| ... | ... |
@@ -17,6 +17,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/builder" |
| 18 | 18 |
"github.com/docker/docker/daemon/config" |
| 19 | 19 |
"github.com/docker/docker/daemon/images" |
| 20 |
+ "github.com/docker/docker/pkg/idtools" |
|
| 20 | 21 |
"github.com/docker/docker/pkg/streamformatter" |
| 21 | 22 |
"github.com/docker/docker/pkg/system" |
| 22 | 23 |
"github.com/docker/libnetwork" |
| ... | ... |
@@ -73,6 +74,7 @@ type Opt struct {
|
| 73 | 73 |
ResolverOpt resolver.ResolveOptionsFunc |
| 74 | 74 |
BuilderConfig config.BuilderConfig |
| 75 | 75 |
Rootless bool |
| 76 |
+ IdentityMapping *idtools.IdentityMapping |
|
| 76 | 77 |
} |
| 77 | 78 |
|
| 78 | 79 |
// Builder can build using BuildKit backend |
| ... | ... |
@@ -38,7 +38,7 @@ import ( |
| 38 | 38 |
) |
| 39 | 39 |
|
| 40 | 40 |
func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
| 41 |
- if err := os.MkdirAll(opt.Root, 0700); err != nil {
|
|
| 41 |
+ if err := os.MkdirAll(opt.Root, 0711); err != nil {
|
|
| 42 | 42 |
return nil, err |
| 43 | 43 |
} |
| 44 | 44 |
|
| ... | ... |
@@ -55,9 +55,10 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
sbase, err := snapshot.NewSnapshotter(snapshot.Opt{
|
| 58 |
- GraphDriver: driver, |
|
| 59 |
- LayerStore: dist.LayerStore, |
|
| 60 |
- Root: root, |
|
| 58 |
+ GraphDriver: driver, |
|
| 59 |
+ LayerStore: dist.LayerStore, |
|
| 60 |
+ Root: root, |
|
| 61 |
+ IdentityMapping: opt.IdentityMapping, |
|
| 61 | 62 |
}) |
| 62 | 63 |
if err != nil {
|
| 63 | 64 |
return nil, err |
| ... | ... |
@@ -112,7 +113,7 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) {
|
| 112 | 112 |
return nil, err |
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 |
- exec, err := newExecutor(root, opt.DefaultCgroupParent, opt.NetworkController, opt.Rootless) |
|
| 115 |
+ exec, err := newExecutor(root, opt.DefaultCgroupParent, opt.NetworkController, opt.Rootless, opt.IdentityMapping) |
|
| 116 | 116 |
if err != nil {
|
| 117 | 117 |
return nil, err |
| 118 | 118 |
} |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"strconv" |
| 9 | 9 |
"sync" |
| 10 | 10 |
|
| 11 |
+ "github.com/docker/docker/pkg/idtools" |
|
| 11 | 12 |
"github.com/docker/libnetwork" |
| 12 | 13 |
"github.com/moby/buildkit/executor" |
| 13 | 14 |
"github.com/moby/buildkit/executor/runcexecutor" |
| ... | ... |
@@ -20,7 +21,7 @@ import ( |
| 20 | 20 |
|
| 21 | 21 |
const networkName = "bridge" |
| 22 | 22 |
|
| 23 |
-func newExecutor(root, cgroupParent string, net libnetwork.NetworkController, rootless bool) (executor.Executor, error) {
|
|
| 23 |
+func newExecutor(root, cgroupParent string, net libnetwork.NetworkController, rootless bool, idmap *idtools.IdentityMapping) (executor.Executor, error) {
|
|
| 24 | 24 |
networkProviders := map[pb.NetMode]network.Provider{
|
| 25 | 25 |
pb.NetMode_UNSET: &bridgeProvider{NetworkController: net, Root: filepath.Join(root, "net")},
|
| 26 | 26 |
pb.NetMode_HOST: network.NewHostProvider(), |
| ... | ... |
@@ -32,6 +33,7 @@ func newExecutor(root, cgroupParent string, net libnetwork.NetworkController, ro |
| 32 | 32 |
DefaultCgroupParent: cgroupParent, |
| 33 | 33 |
Rootless: rootless, |
| 34 | 34 |
NoPivot: os.Getenv("DOCKER_RAMDISK") != "",
|
| 35 |
+ IdentityMapping: idmap, |
|
| 35 | 36 |
}, networkProviders) |
| 36 | 37 |
} |
| 37 | 38 |
|
| ... | ... |
@@ -5,12 +5,13 @@ import ( |
| 5 | 5 |
"errors" |
| 6 | 6 |
"io" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/pkg/idtools" |
|
| 8 | 9 |
"github.com/docker/libnetwork" |
| 9 | 10 |
"github.com/moby/buildkit/cache" |
| 10 | 11 |
"github.com/moby/buildkit/executor" |
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 |
-func newExecutor(_, _ string, _ libnetwork.NetworkController, _ bool) (executor.Executor, error) {
|
|
| 14 |
+func newExecutor(_, _ string, _ libnetwork.NetworkController, _ bool, _ *idtools.IdentityMapping) (executor.Executor, error) {
|
|
| 14 | 15 |
return &winExecutor{}, nil
|
| 15 | 16 |
} |
| 16 | 17 |
|
| ... | ... |
@@ -318,6 +318,7 @@ func newRouterOptions(config *config.Config, d *daemon.Daemon) (routerOptions, e |
| 318 | 318 |
ResolverOpt: d.NewResolveOptionsFunc(), |
| 319 | 319 |
BuilderConfig: config.Builder, |
| 320 | 320 |
Rootless: d.Rootless(), |
| 321 |
+ IdentityMapping: d.IdentityMapping(), |
|
| 321 | 322 |
}) |
| 322 | 323 |
if err != nil {
|
| 323 | 324 |
return opts, err |