Combine topic on commands and args. (#3637)
* Combine topic on commands and args. * Fix redirect.reviewable/pr3638/r1
parent
1cc0b4b93a
commit
fc533bea91
|
@ -86,7 +86,6 @@ toc:
|
|||
- title: Configuration
|
||||
section:
|
||||
- docs/concepts/configuration/overview.md
|
||||
- docs/concepts/configuration/container-command-args.md
|
||||
- docs/concepts/configuration/manage-compute-resources-container.md
|
||||
- docs/concepts/configuration/assign-pod-node.md
|
||||
- docs/concepts/configuration/secret.md
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
---
|
||||
title: Container Command and Arguments
|
||||
redirect_from:
|
||||
- "/docs/user-guide/containers/"
|
||||
- "/docs/user-guide/containers.html"
|
||||
---
|
||||
|
||||
{% capture overview %}
|
||||
|
||||
In the configuration file for a Container, you can set the `command` and `args`
|
||||
fields to override the default Entrypoint and Cmd of the the Container's image.
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
{% capture body %}
|
||||
|
||||
## Container entry points and arguments
|
||||
|
||||
The configuration file for a Container has an `image` field that specifies
|
||||
the Docker image to be run in the Container. A Docker image has metadata that includes
|
||||
a default Entrypoint and a default Cmd.
|
||||
|
||||
When Kubernetes starts a Container, it runs the image's default Entrypoint and
|
||||
passes the image's default Cmd as arguments.
|
||||
|
||||
If you want override the image's default Entrypoint and Cmd, you can use the
|
||||
`command` and `args` fields in the Container's configuration.
|
||||
|
||||
* The `command` field specifies the actual command run by the Container.
|
||||
* The `args` field specifies the arguments passed to the command.
|
||||
|
||||
This table summarizes the field names used by Docker and Kubernetes.
|
||||
|
||||
| Description | Docker field name | Kubernetes field name |
|
||||
|----------------------------------------|------------------------|-----------------------|
|
||||
| The command run by the container | Entrypoint | command |
|
||||
| The arguments passed to the command | Cmd | args |
|
||||
|
||||
Here's an example of a configuration file for a Pod that has one Container.
|
||||
|
||||
{% include code.html language="yaml" file="commands.yaml" ghlink="/docs/concepts/configuration/commands.yaml" %}
|
||||
|
||||
When Kubernetes starts the Container, it runs this command:
|
||||
|
||||
```shell
|
||||
printenv HOSTNAME KUBERNETES_PORT
|
||||
```
|
||||
|
||||
When you override the default Entrypoint and Cmd, these rules apply:
|
||||
|
||||
* If you do not supply `command` or `args` for a Container, the defaults defined
|
||||
in the Docker image are used.
|
||||
|
||||
* If you supply a `command` but no `args` for a Container, only the supplied
|
||||
`command` is used. The default EntryPoint and the default Cmd defined in the Docker
|
||||
image are ignored.
|
||||
|
||||
* If you supply only `args` for a Container, the default Entrypoint defined in
|
||||
the Docker image is run with the `args` that you supplied.
|
||||
|
||||
* If you supply a `command` and `args`, the default Entrypoint and the default
|
||||
Cmd defined in the Docker image are ignored. Your `command` is run with your
|
||||
`args`.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
| Image Entrypoint | Image Cmd | Container command | Container args | Command run |
|
||||
|--------------------|------------------|---------------------|--------------------|------------------|
|
||||
| `[/ep-1]` | `[foo bar]` | <not set> | <not set> | `[ep-1 foo bar]` |
|
||||
| `[/ep-1]` | `[foo bar]` | `[/ep-2]` | <not set> | `[ep-2]` |
|
||||
| `[/ep-1]` | `[foo bar]` | <not set> | `[zoo boo]` | `[ep-1 zoo boo]` |
|
||||
| `[/ep-1]` | `[foo bar]` | `[/ep-2]` | `[zoo boo]` | `[ep-2 zoo boo]` |
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
{% capture whatsnext %}
|
||||
|
||||
* [Defining a Command and Arguments for a Container](/docs/tasks/configure-pod-container/define-command-argument-container/)
|
||||
|
||||
* [Getting a Shell to a Running Container](/docs/tasks/kubectl/get-shell-running-container/)
|
||||
|
||||
* [Container](/docs/api-reference/v1.6/#container-v1-core)
|
||||
|
||||
* [Docker Entrypoint field](https://docs.docker.com/engine/reference/builder/)
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
{% include templates/concept.md %}
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: Defining a Command and Arguments for a Container
|
||||
redirect_from:
|
||||
- "/docs/tasks/configure-pod-container/define-command-argument-container/"
|
||||
- "/docs/tasks/configure-pod-container/define-command-argument-container.html"
|
||||
- "/docs/concepts/configuration/container-command-args/"
|
||||
- "/docs/concepts/configuration/container-command-arg.html"
|
||||
---
|
||||
|
||||
{% capture overview %}
|
||||
|
@ -33,8 +33,7 @@ you define cannot be changed after the Pod is created.
|
|||
The command and arguments that you define in the configuration file
|
||||
override the default command and arguments provided by the container image.
|
||||
If you define args, but do not define a command, the default command is used
|
||||
with your new arguments. For more information, see
|
||||
[Commands and Capabilities](/docs/user-guide/containers/).
|
||||
with your new arguments.
|
||||
|
||||
In this exercise, you create a Pod that runs one container. The configuration
|
||||
file for the Pod defines a command and two arguments:
|
||||
|
@ -93,6 +92,41 @@ script. To run your command in a shell, wrap it like this:
|
|||
command: ["/bin/sh"]
|
||||
args: ["-c", "while true; do echo hello; sleep 10;done"]
|
||||
|
||||
## Notes
|
||||
|
||||
This table summarizes the field names used by Docker and Kubernetes.
|
||||
|
||||
| Description | Docker field name | Kubernetes field name |
|
||||
|----------------------------------------|------------------------|-----------------------|
|
||||
| The command run by the container | Entrypoint | command |
|
||||
| The arguments passed to the command | Cmd | args |
|
||||
|
||||
When you override the default Entrypoint and Cmd, these rules apply:
|
||||
|
||||
* If you do not supply `command` or `args` for a Container, the defaults defined
|
||||
in the Docker image are used.
|
||||
|
||||
* If you supply a `command` but no `args` for a Container, only the supplied
|
||||
`command` is used. The default EntryPoint and the default Cmd defined in the Docker
|
||||
image are ignored.
|
||||
|
||||
* If you supply only `args` for a Container, the default Entrypoint defined in
|
||||
the Docker image is run with the `args` that you supplied.
|
||||
|
||||
* If you supply a `command` and `args`, the default Entrypoint and the default
|
||||
Cmd defined in the Docker image are ignored. Your `command` is run with your
|
||||
`args`.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
| Image Entrypoint | Image Cmd | Container command | Container args | Command run |
|
||||
|--------------------|------------------|---------------------|--------------------|------------------|
|
||||
| `[/ep-1]` | `[foo bar]` | <not set> | <not set> | `[ep-1 foo bar]` |
|
||||
| `[/ep-1]` | `[foo bar]` | `[/ep-2]` | <not set> | `[ep-2]` |
|
||||
| `[/ep-1]` | `[foo bar]` | <not set> | `[zoo boo]` | `[ep-1 zoo boo]` |
|
||||
| `[/ep-1]` | `[foo bar]` | `[/ep-2]` | `[zoo boo]` | `[ep-2 zoo boo]` |
|
||||
|
||||
|
||||
{% endcapture %}
|
||||
|
||||
{% capture whatsnext %}
|
||||
|
|
Loading…
Reference in New Issue