mirror of
https://github.com/docker/compose.git
synced 2026-08-31 06:49:15 +00:00
Add Restart Policy support when running single container
This commit is contained in:
parent
2c4be4f7e3
commit
a2c2d6aa5d
12 changed files with 189 additions and 48 deletions
|
|
@ -52,6 +52,7 @@ func Command() *cobra.Command {
|
|||
cmd.Flags().Float64Var(&opts.Cpus, "cpus", 1., "Number of CPUs")
|
||||
cmd.Flags().VarP(&opts.Memory, "memory", "m", "Memory limit")
|
||||
cmd.Flags().StringArrayVarP(&opts.Environment, "env", "e", []string{}, "Set environment variables")
|
||||
cmd.Flags().StringVarP(&opts.RestartPolicyCondition, "restart", "", "no", "Restart policy to apply when a container exits")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
|
|||
1
cli/cmd/run/testdata/run-help.golden
vendored
1
cli/cmd/run/testdata/run-help.golden
vendored
|
|
@ -11,4 +11,5 @@ Flags:
|
|||
-m, --memory bytes Memory limit
|
||||
--name string Assign a name to the container
|
||||
-p, --publish stringArray Publish a container's port(s). [HOST_PORT:]CONTAINER_PORT
|
||||
--restart string Restart policy to apply when a container exits (default "no")
|
||||
-v, --volume stringArray Volume. Ex: user:key@my_share:/absolute/path/to/target
|
||||
|
|
|
|||
3
cli/cmd/testdata/inspect-out-id.golden
vendored
3
cli/cmd/testdata/inspect-out-id.golden
vendored
|
|
@ -11,5 +11,6 @@
|
|||
"PidsLimit": 0,
|
||||
"Labels": null,
|
||||
"Ports": null,
|
||||
"Platform": "Linux"
|
||||
"Platform": "Linux",
|
||||
"RestartPolicyCondition": ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,15 @@ import (
|
|||
|
||||
// Opts contain run command options
|
||||
type Opts struct {
|
||||
Name string
|
||||
Publish []string
|
||||
Labels []string
|
||||
Volumes []string
|
||||
Cpus float64
|
||||
Memory formatter.MemBytes
|
||||
Detach bool
|
||||
Environment []string
|
||||
Name string
|
||||
Publish []string
|
||||
Labels []string
|
||||
Volumes []string
|
||||
Cpus float64
|
||||
Memory formatter.MemBytes
|
||||
Detach bool
|
||||
Environment []string
|
||||
RestartPolicyCondition string
|
||||
}
|
||||
|
||||
// ToContainerConfig convert run options to a container configuration
|
||||
|
|
@ -57,14 +58,15 @@ func (r *Opts) ToContainerConfig(image string) (containers.ContainerConfig, erro
|
|||
}
|
||||
|
||||
return containers.ContainerConfig{
|
||||
ID: r.Name,
|
||||
Image: image,
|
||||
Ports: publish,
|
||||
Labels: labels,
|
||||
Volumes: r.Volumes,
|
||||
MemLimit: r.Memory,
|
||||
CPULimit: r.Cpus,
|
||||
Environment: r.Environment,
|
||||
ID: r.Name,
|
||||
Image: image,
|
||||
Ports: publish,
|
||||
Labels: labels,
|
||||
Volumes: r.Volumes,
|
||||
MemLimit: r.Memory,
|
||||
CPULimit: r.Cpus,
|
||||
Environment: r.Environment,
|
||||
RestartPolicyCondition: r.RestartPolicyCondition,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue