mirror of
https://github.com/docker/compose.git
synced 2025-06-19 13:10:21 +02:00
add --pull to run command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
ed61e42f93
commit
34bcd03a76
@ -154,6 +154,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
|
|||||||
options.noTty = !options.tty
|
options.noTty = !options.tty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
createOpts.pullChanged = cmd.Flags().Changed("pull")
|
||||||
return nil
|
return nil
|
||||||
}),
|
}),
|
||||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
RunE: Adapt(func(ctx context.Context, args []string) error {
|
||||||
@ -188,6 +189,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
|
|||||||
flags.StringArrayVarP(&options.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host")
|
flags.StringArrayVarP(&options.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host")
|
||||||
flags.BoolVar(&options.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to")
|
flags.BoolVar(&options.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to")
|
||||||
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
|
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
|
||||||
|
flags.StringVar(&createOpts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
|
||||||
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
|
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
|
||||||
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
|
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
|
||||||
flags.BoolVar(&options.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
|
flags.BoolVar(&options.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
|
||||||
|
@ -58,7 +58,7 @@ specified in the service configuration.
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:--------------|:--------|:---------------------------------------------------------------------------------|
|
|:------------------------|:--------------|:---------|:---------------------------------------------------------------------------------|
|
||||||
| `--build` | `bool` | | Build image before starting container |
|
| `--build` | `bool` | | Build image before starting container |
|
||||||
| `--cap-add` | `list` | | Add Linux capabilities |
|
| `--cap-add` | `list` | | Add Linux capabilities |
|
||||||
| `--cap-drop` | `list` | | Drop Linux capabilities |
|
| `--cap-drop` | `list` | | Drop Linux capabilities |
|
||||||
@ -72,6 +72,7 @@ specified in the service configuration.
|
|||||||
| `-T`, `--no-TTY` | `bool` | `true` | Disable pseudo-TTY allocation (default: auto-detected) |
|
| `-T`, `--no-TTY` | `bool` | `true` | Disable pseudo-TTY allocation (default: auto-detected) |
|
||||||
| `--no-deps` | `bool` | | Don't start linked services |
|
| `--no-deps` | `bool` | | Don't start linked services |
|
||||||
| `-p`, `--publish` | `stringArray` | | Publish a container's port(s) to the host |
|
| `-p`, `--publish` | `stringArray` | | Publish a container's port(s) to the host |
|
||||||
|
| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") |
|
||||||
| `--quiet-pull` | `bool` | | Pull without printing progress information |
|
| `--quiet-pull` | `bool` | | Pull without printing progress information |
|
||||||
| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file |
|
| `--remove-orphans` | `bool` | | Remove containers for services not defined in the Compose file |
|
||||||
| `--rm` | `bool` | | Automatically remove the container when it exits |
|
| `--rm` | `bool` | | Automatically remove the container when it exits |
|
||||||
|
@ -180,6 +180,16 @@ options:
|
|||||||
experimentalcli: false
|
experimentalcli: false
|
||||||
kubernetes: false
|
kubernetes: false
|
||||||
swarm: false
|
swarm: false
|
||||||
|
- option: pull
|
||||||
|
value_type: string
|
||||||
|
default_value: policy
|
||||||
|
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"
|
||||||
|
@ -169,4 +169,14 @@ func TestLocalComposeRun(t *testing.T) {
|
|||||||
assert.Assert(t, !strings.Contains(res.Combined(), "Pull complete"), res.Combined())
|
assert.Assert(t, !strings.Contains(res.Combined(), "Pull complete"), res.Combined())
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "Pulled"), res.Combined())
|
assert.Assert(t, strings.Contains(res.Combined(), "Pulled"), res.Combined())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("--pull", func(t *testing.T) {
|
||||||
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "down", "--rmi", "all")
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
|
||||||
|
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "run", "--pull", "always", "backend")
|
||||||
|
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulling"), res.Combined())
|
||||||
|
assert.Assert(t, strings.Contains(res.Combined(), "Download complete"), res.Combined())
|
||||||
|
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulled"), res.Combined())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
4
pkg/e2e/fixtures/run-test/pull.yaml
Normal file
4
pkg/e2e/fixtures/run-test/pull.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: nginx
|
||||||
|
command: nginx -t
|
Loading…
x
Reference in New Issue
Block a user