mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
commit
085d8e9bb7
@ -30,6 +30,7 @@ import (
|
|||||||
type createOptions struct {
|
type createOptions struct {
|
||||||
Build bool
|
Build bool
|
||||||
noBuild bool
|
noBuild bool
|
||||||
|
Pull string
|
||||||
removeOrphans bool
|
removeOrphans bool
|
||||||
ignoreOrphans bool
|
ignoreOrphans bool
|
||||||
forceRecreate bool
|
forceRecreate bool
|
||||||
@ -56,6 +57,7 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
RunE: p.WithProject(func(ctx context.Context, project *types.Project) error {
|
RunE: p.WithProject(func(ctx context.Context, project *types.Project) error {
|
||||||
|
opts.Apply(project)
|
||||||
return backend.Create(ctx, project, api.CreateOptions{
|
return backend.Create(ctx, project, api.CreateOptions{
|
||||||
RemoveOrphans: opts.removeOrphans,
|
RemoveOrphans: opts.removeOrphans,
|
||||||
IgnoreOrphans: opts.ignoreOrphans,
|
IgnoreOrphans: opts.ignoreOrphans,
|
||||||
@ -71,6 +73,7 @@ func createCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||||||
flags := cmd.Flags()
|
flags := cmd.Flags()
|
||||||
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
|
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
|
||||||
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
|
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
|
||||||
|
flags.StringVar(&opts.Pull, "pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
|
||||||
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
|
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
|
||||||
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
|
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
|
||||||
return cmd
|
return cmd
|
||||||
@ -105,6 +108,12 @@ func (opts createOptions) GetTimeout() *time.Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (opts createOptions) Apply(project *types.Project) {
|
func (opts createOptions) Apply(project *types.Project) {
|
||||||
|
if opts.Pull != "" {
|
||||||
|
for i, service := range project.Services {
|
||||||
|
service.PullPolicy = opts.Pull
|
||||||
|
project.Services[i] = service
|
||||||
|
}
|
||||||
|
}
|
||||||
if opts.Build {
|
if opts.Build {
|
||||||
for i, service := range project.Services {
|
for i, service := range project.Services {
|
||||||
if service.Build == nil {
|
if service.Build == nil {
|
||||||
|
@ -115,6 +115,7 @@ func upCommand(p *projectOptions, backend api.Service) *cobra.Command {
|
|||||||
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
|
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
|
||||||
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.")
|
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.")
|
||||||
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
|
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's missing.")
|
||||||
|
flags.StringVar(&create.Pull, "pull", "missing", `Pull image before running ("always"|"missing"|"never")`)
|
||||||
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
|
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
|
||||||
flags.StringArrayVar(&up.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
|
flags.StringArrayVar(&up.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
|
||||||
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.")
|
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.")
|
||||||
|
@ -11,6 +11,7 @@ Creates containers for a service.
|
|||||||
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed. |
|
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed. |
|
||||||
| `--no-build` | | | Don't build an image, even if it's missing. |
|
| `--no-build` | | | Don't build an image, even if it's missing. |
|
||||||
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
|
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
|
||||||
|
| `--pull` | `string` | `missing` | Pull image before running ("always"\|"missing"\|"never") |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
@ -21,6 +21,7 @@ Create and start containers
|
|||||||
| `--no-log-prefix` | | | Don't print prefix in logs. |
|
| `--no-log-prefix` | | | Don't print prefix in logs. |
|
||||||
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
|
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
|
||||||
| `--no-start` | | | Don't start the services after creating them. |
|
| `--no-start` | | | Don't start the services after creating them. |
|
||||||
|
| `--pull` | `string` | `missing` | Pull image before running ("always"\|"missing"\|"never") |
|
||||||
| `--quiet-pull` | | | Pull without printing progress information. |
|
| `--quiet-pull` | | | Pull without printing progress information. |
|
||||||
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
|
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
|
||||||
| `-V`, `--renew-anon-volumes` | | | Recreate anonymous volumes instead of retrieving data from the previous containers. |
|
| `-V`, `--renew-anon-volumes` | | | Recreate anonymous volumes instead of retrieving data from the previous containers. |
|
||||||
|
@ -47,6 +47,16 @@ options:
|
|||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: pull
|
||||||
|
value_type: string
|
||||||
|
default_value: missing
|
||||||
|
description: Pull image before running ("always"|"missing"|"never")
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
deprecated: false
|
deprecated: false
|
||||||
experimental: false
|
experimental: false
|
||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
|
@ -165,6 +165,16 @@ options:
|
|||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: pull
|
||||||
|
value_type: string
|
||||||
|
default_value: missing
|
||||||
|
description: Pull image before running ("always"|"missing"|"never")
|
||||||
|
deprecated: false
|
||||||
|
hidden: false
|
||||||
|
experimental: false
|
||||||
|
experimentalcli: false
|
||||||
|
kubernetes: false
|
||||||
|
swarm: false
|
||||||
- option: quiet-pull
|
- option: quiet-pull
|
||||||
value_type: bool
|
value_type: bool
|
||||||
default_value: "false"
|
default_value: "false"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user