7.7. Executing remote commands in an OpenShift Container Platform container


You can use the oc exec command to execute remote commands in OpenShift Container Platform containers from your local machine.

7.7.1. Executing remote commands in containers

You can use the OpenShift CLI (oc) to execute remote commands in OpenShift Container Platform containers. By running commands in a container, you can perform troubleshooting, inspect logs, run scripts, and other tasks.

Procedure

  • Use a command similar to the following to run a command in a container:

    $ oc exec <pod> [-c <container>] -- <command> [<arg_1> ... <arg_n>]

    For example:

    $ oc exec mypod date

    Example output

    Thu Apr  9 02:21:53 UTC 2015

    重要

    For security purposes, the oc exec command does not work when accessing privileged containers except when the command is executed by a cluster-admin user.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部