windows process shim installer
Signed-off-by: Ameya Gawde <ameya.gawde@docker.com>
This commit is contained in:
parent
342ce3e602
commit
d21f0f116e
@ -91,3 +91,15 @@ ctr: OCI runtime create failed: unable to retrieve OCI runtime error (open /run/
|
||||
1:M 01 Aug 15:59:53.484 * DB saved on disk
|
||||
1:M 01 Aug 15:59:53.484 # Redis is now ready to exit, bye bye...
|
||||
```
|
||||
For Windows:
|
||||
|
||||
```Dockerfile
|
||||
FROM mcr.microsoft.com/windows/nanoserver:1809
|
||||
ADD runhcs.exe /bin/runhcs.exe
|
||||
```
|
||||
|
||||
```powershell
|
||||
> ctr content fetch docker.io/ameyagawde/runhcs:1809 #An example image, not supported by containerd
|
||||
> ctr install docker.io/ameyagawde/runhcs:1809
|
||||
```
|
||||
The Windows equivalent for `/opt/containerd` will be `$env:ProgramData\containerd\root\opt`
|
20
install.go
20
install.go
@ -21,6 +21,8 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
introspectionapi "github.com/containerd/containerd/api/services/introspection/v1"
|
||||
"github.com/containerd/containerd/archive"
|
||||
@ -48,6 +50,15 @@ func (c *Client) Install(ctx context.Context, image Image, opts ...InstallOpts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var binDir, libDir string
|
||||
if runtime.GOOS == "windows" {
|
||||
binDir = "Files\\bin"
|
||||
libDir = "Files\\lib"
|
||||
} else {
|
||||
binDir = "bin"
|
||||
libDir = "lib"
|
||||
}
|
||||
for _, layer := range manifest.Layers {
|
||||
ra, err := cs.ReaderAt(ctx, layer)
|
||||
if err != nil {
|
||||
@ -60,9 +71,14 @@ func (c *Client) Install(ctx context.Context, image Image, opts ...InstallOpts)
|
||||
}
|
||||
if _, err := archive.Apply(ctx, path, r, archive.WithFilter(func(hdr *tar.Header) (bool, error) {
|
||||
d := filepath.Dir(hdr.Name)
|
||||
result := d == "bin"
|
||||
result := d == binDir
|
||||
|
||||
if config.Libs {
|
||||
result = result || d == "lib"
|
||||
result = result || d == libDir
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
hdr.Name = strings.Replace(hdr.Name, "Files", "", 1)
|
||||
}
|
||||
if result && !config.Replace {
|
||||
if _, err := os.Lstat(filepath.Join(path, hdr.Name)); err == nil {
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/pkg/errors"
|
||||
@ -42,23 +41,21 @@ func init() {
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
path := ic.Config.(*Config).Path
|
||||
ic.Meta.Exports["path"] = path
|
||||
|
||||
bin := filepath.Join(path, "bin")
|
||||
if err := os.MkdirAll(bin, 0711); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Setenv("PATH", fmt.Sprintf("%s:%s", bin, os.Getenv("PATH"))); err != nil {
|
||||
if err := os.Setenv("PATH", fmt.Sprintf("%s%c%s", bin, os.PathListSeparator, os.Getenv("PATH"))); err != nil {
|
||||
return nil, errors.Wrapf(err, "set binary image directory in path %s", bin)
|
||||
}
|
||||
if runtime.GOOS != "windows" {
|
||||
|
||||
lib := filepath.Join(path, "lib")
|
||||
if err := os.MkdirAll(lib, 0711); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := os.Setenv("LD_LIBRARY_PATH", fmt.Sprintf("%s:%s", os.Getenv("LD_LIBRARY_PATH"), lib)); err != nil {
|
||||
if err := os.Setenv("LD_LIBRARY_PATH", fmt.Sprintf("%s%c%s", lib, os.PathListSeparator, os.Getenv("LD_LIBRARY_PATH"))); err != nil {
|
||||
return nil, errors.Wrapf(err, "set binary lib directory in path %s", lib)
|
||||
}
|
||||
}
|
||||
return &manager{}, nil
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user