mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
70 lines
2.2 KiB
Plaintext
70 lines
2.2 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * serverless/reference/kn-serving-ref.adoc
|
|
|
|
:_mod-docs-content-type: REFERENCE
|
|
[id="serverless-kn-container_{context}"]
|
|
= Knative client multi-container support
|
|
|
|
You can use the `kn container add` command to print YAML container spec to standard output. This command is useful for multi-container use cases because it can be used along with other standard `kn` flags to create definitions.
|
|
|
|
The `kn container add` command accepts all container-related flags that are supported for use with the `kn service create` command. The `kn container add` command can also be chained by using UNIX pipes (`|`) to create multiple container definitions at once.
|
|
|
|
|
|
[id="serverless-kn-container-examples_{context}"]
|
|
== Example commands
|
|
|
|
* Add a container from an image and print it to standard output:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ kn container add <container_name> --image <image_uri>
|
|
----
|
|
+
|
|
.Example command
|
|
[source,terminal]
|
|
----
|
|
$ kn container add sidecar --image docker.io/example/sidecar
|
|
----
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
containers:
|
|
- image: docker.io/example/sidecar
|
|
name: sidecar
|
|
resources: {}
|
|
----
|
|
|
|
* Chain two `kn container add` commands together, and then pass them to a `kn service create` command to create a Knative service with two containers:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ kn container add <first_container_name> --image <image_uri> | \
|
|
kn container add <second_container_name> --image <image_uri> | \
|
|
kn service create <service_name> --image <image_uri> --extra-containers -
|
|
----
|
|
+
|
|
`--extra-containers -` specifies a special case where `kn` reads the pipe input instead of a YAML file.
|
|
+
|
|
.Example command
|
|
[source,terminal]
|
|
----
|
|
$ kn container add sidecar --image docker.io/example/sidecar:first | \
|
|
kn container add second --image docker.io/example/sidecar:second | \
|
|
kn service create my-service --image docker.io/example/my-app:latest --extra-containers -
|
|
----
|
|
+
|
|
The `--extra-containers` flag can also accept a path to a YAML file:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ kn service create <service_name> --image <image_uri> --extra-containers <filename>
|
|
----
|
|
+
|
|
.Example command
|
|
[source,terminal]
|
|
----
|
|
$ kn service create my-service --image docker.io/example/my-app:latest --extra-containers my-extra-containers.yaml
|
|
----
|