mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
60 lines
1.5 KiB
Plaintext
60 lines
1.5 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * applications/deployments/managing-deployment-processes.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="deployments-exe-cmd-in-container_{context}"]
|
|
= Executing commands inside a container
|
|
|
|
You can add a command to a container, which modifies the container's startup behavior by overruling the image's `ENTRYPOINT`. This is different from a lifecycle hook, which instead can be run once per deployment at a specified time.
|
|
|
|
.Procedure
|
|
|
|
. Add the `command` parameters to the `spec` field of the `DeploymentConfig` object. You can also add an `args` field, which modifies the `command` (or the `ENTRYPOINT` if `command` does not exist).
|
|
+
|
|
[source,yaml]
|
|
----
|
|
kind: DeploymentConfig
|
|
apiVersion: apps.openshift.io/v1
|
|
metadata:
|
|
name: example-dc
|
|
# ...
|
|
spec:
|
|
template:
|
|
# ...
|
|
spec:
|
|
containers:
|
|
- name: <container_name>
|
|
image: 'image'
|
|
command:
|
|
- '<command>'
|
|
args:
|
|
- '<argument_1>'
|
|
- '<argument_2>'
|
|
- '<argument_3>'
|
|
----
|
|
+
|
|
For example, to execute the `java` command with the `-jar` and `/opt/app-root/springboots2idemo.jar` arguments:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
kind: DeploymentConfig
|
|
apiVersion: apps.openshift.io/v1
|
|
metadata:
|
|
name: example-dc
|
|
# ...
|
|
spec:
|
|
template:
|
|
# ...
|
|
spec:
|
|
containers:
|
|
- name: example-spring-boot
|
|
image: 'image'
|
|
command:
|
|
- java
|
|
args:
|
|
- '-jar'
|
|
- /opt/app-root/springboots2idemo.jar
|
|
# ...
|
|
----
|