docker-container: restart-policy opt
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -153,6 +153,7 @@ No driver options.
|
||||
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
||||
- `network=NETMODE` - Sets the network mode for running the buildkit container.
|
||||
- `cgroup-parent=CGROUP` - Sets the cgroup parent of the buildkit container if docker is using the "cgroupfs" driver. Defaults to `/docker/buildx`.
|
||||
- `restart-policy=POLICY` - Sets the [restart policy](https://docs.docker.com/engine/reference/run/#restart-policies---restart) of the buildkit container.
|
||||
|
||||
#### `kubernetes` driver
|
||||
|
||||
|
||||
@@ -35,11 +35,12 @@ const (
|
||||
|
||||
type Driver struct {
|
||||
driver.InitConfig
|
||||
factory driver.Factory
|
||||
netMode string
|
||||
image string
|
||||
cgroupParent string
|
||||
env []string
|
||||
factory driver.Factory
|
||||
netMode string
|
||||
image string
|
||||
cgroupParent string
|
||||
restartPolicy container.RestartPolicy
|
||||
env []string
|
||||
}
|
||||
|
||||
func (d *Driver) IsMobyDriver() bool {
|
||||
@@ -110,7 +111,8 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
||||
|
||||
if err := l.Wrap("creating container "+d.Name, func() error {
|
||||
hc := &container.HostConfig{
|
||||
Privileged: true,
|
||||
Privileged: true,
|
||||
RestartPolicy: d.restartPolicy,
|
||||
Mounts: []mount.Mount{
|
||||
{
|
||||
Type: mount.TypeVolume,
|
||||
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/docker/buildx/driver"
|
||||
dockeropts "github.com/docker/cli/opts"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const prioritySupported = 30
|
||||
const priorityUnsupported = 70
|
||||
const defaultRestartPolicy = "unless-stopped"
|
||||
|
||||
func init() {
|
||||
driver.Register(&factory{})
|
||||
@@ -39,7 +41,15 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
|
||||
if cfg.DockerAPI == nil {
|
||||
return nil, errors.Errorf("%s driver requires docker API access", f.Name())
|
||||
}
|
||||
d := &Driver{factory: f, InitConfig: cfg}
|
||||
rp, err := dockeropts.ParseRestartPolicy(defaultRestartPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d := &Driver{
|
||||
factory: f,
|
||||
InitConfig: cfg,
|
||||
restartPolicy: rp,
|
||||
}
|
||||
for k, v := range cfg.DriverOpts {
|
||||
switch {
|
||||
case k == "network":
|
||||
@@ -51,6 +61,11 @@ func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver
|
||||
d.image = v
|
||||
case k == "cgroup-parent":
|
||||
d.cgroupParent = v
|
||||
case k == "restart-policy":
|
||||
d.restartPolicy, err = dockeropts.ParseRestartPolicy(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case strings.HasPrefix(k, "env."):
|
||||
envName := strings.TrimPrefix(k, "env.")
|
||||
if envName == "" {
|
||||
|
||||
Reference in New Issue
Block a user