fix docker container creation for metabase (#563)

This commit is contained in:
AlteredCoder 2021-01-08 14:32:29 +01:00 committed by GitHub
parent eda9c03c82
commit c2517e8eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

4
go.mod
View file

@ -17,7 +17,7 @@ require (
github.com/denisbrodbeck/machineid v1.0.1
github.com/dghubble/sling v1.3.0
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v17.12.0-ce-rc1.0.20200419140219-55e6d7d36faf+incompatible
github.com/docker/docker v20.10.2+incompatible
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/enescakir/emoji v1.0.0
@ -51,7 +51,7 @@ require (
github.com/nxadm/tail v1.4.4
github.com/olekukonko/tablewriter v0.0.4
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/image-spec v1.0.1
github.com/oschwald/geoip2-golang v1.4.0
github.com/oschwald/maxminddb-golang v1.6.0
github.com/pkg/errors v0.9.1

2
go.sum
View file

@ -125,6 +125,8 @@ github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v17.12.0-ce-rc1.0.20200419140219-55e6d7d36faf+incompatible h1:QDfFL8R7RwJTBJKkJuSNGs0SYjyxnwikV/kojSTLi2E=
github.com/docker/docker v17.12.0-ce-rc1.0.20200419140219-55e6d7d36faf+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.2+incompatible h1:vFgEHPqWBTp4pTjdLwjAA4bSo3gvIGOYwuJTlEjVBCw=
github.com/docker/docker v20.10.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=

View file

@ -4,6 +4,7 @@ import (
"bufio"
"context"
"fmt"
"runtime"
"time"
"github.com/docker/docker/api/types"
@ -11,6 +12,7 @@ import (
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
log "github.com/sirupsen/logrus"
)
@ -89,8 +91,22 @@ func (c *Container) Create() error {
Env: env,
}
os := runtime.GOOS
switch os {
case "linux":
case "windows", "darwin":
return fmt.Errorf("Mac and Windows are not supported yet")
default:
return fmt.Errorf("OS '%s' is not supported", os)
}
arch := runtime.GOARCH
platform := &v1.Platform{
Architecture: arch,
OS: os,
}
log.Infof("creating container '%s'", c.Name)
resp, err := c.CLI.ContainerCreate(ctx, dockerConfig, hostConfig, nil, c.Name)
resp, err := c.CLI.ContainerCreate(ctx, dockerConfig, hostConfig, nil, platform, c.Name)
if err != nil {
return fmt.Errorf("failed to create container : %s", err)
}