oc Rsh Examples¶
Introduction¶
oc rsh and oc exec run commands inside a container. Use them to inspect files, environment, DNS, and local network behavior from the same environment as the application.
When You Need This Command¶
Use this command when you need to inspect, change, or verify OpenShift resources from the terminal without relying on the web console.
Syntax¶
oc <command> <resource> [name] -n <project>
Practical Examples¶
oc rsh deployment/web -n app
oc exec deployment/web -n app -- printenv APP_MODE
oc exec deployment/web -n app -- curl -sS http://api:8080/health
oc exec deployment/web -n app -- ls -l /opt/app-root/src
Example output:
APP_MODE=production
OK
Verification¶
oc get events -n app --sort-by=.lastTimestamp
oc get pods -n app -o wide
Common Mistakes¶
- Looking only at the final error and ignoring events.
- Checking the wrong project with oc.
- Changing several objects at once before confirming the current state.
Production Notes¶
Run read-only commands first, check the active project, and prefer declarative manifests for repeatable changes.
Quick Checklist¶
- Confirm the active project.
- Inspect the exact object named in the error.
- Read recent events.
- Apply one focused fix.
- Verify status after the change.
Related Guides¶
Summary¶
oc Rsh Examples is most useful when paired with verification. Check the project, run the command against the intended object, and confirm the resulting OpenShift state.