From 9b18efd3345496aa1e078a3c00b1b184ffec33a9 Mon Sep 17 00:00:00 2001 From: steveperry-53 Date: Thu, 20 Oct 2016 16:36:00 -0700 Subject: [PATCH] Write new task: Defining a Command and Arguments for a Container 2 --- .../define-command-argument-container.md | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/tasks/configure-pod-container/define-command-argument-container.md b/docs/tasks/configure-pod-container/define-command-argument-container.md index bbff487674..1e623d9b43 100644 --- a/docs/tasks/configure-pod-container/define-command-argument-container.md +++ b/docs/tasks/configure-pod-container/define-command-argument-container.md @@ -18,13 +18,19 @@ in a Kubernetes Pod. {% capture steps %} -### Defining a command when you create a Pod +### Defining a command and arguments when you create a Pod -When you create a Pod, you can specify a command and arguments for the -containers that run in the Pod. To specify a command, include the `command` -field in the configuration file. To specify arguments for the command, include -the `args` field in the configuration file. The command that you specify in the -configuration file overrides the usual entry point for the container. +When you create a Pod, you can define a command and arguments for the +containers that run in the Pod. To define a command, include the `command` +field in the configuration file. To define arguments for the command, include +the `args` field in the configuration file. The command and arguments that +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/). In this exercise, you create a Pod that runs one container. The configuration file for the Pod defines a command and two arguments: @@ -54,6 +60,24 @@ from the Pod: command-demo tcp://10.3.240.1:443 +### Using environment variables to define arguments + +In the preceding example, you defined the arguments directly by +providing strings. As an alternative to providing strings directly, +you can define arguments by using environment variables. + + env: + - name: MESSAGE + value: "hello world" + command: ["/bin/echo"] + args: ["$(MESSAGE)"] + +This means you can define an argument for a Pod using any of +the techniques available for defining environment variables, including +[ConfigMaps](/docs/user-guide/configmap/) +and +[Secrets](/docs/user-guide/secrets/). + {% endcapture %} {% capture whatsnext %}