0

We have two container in one pod. One container is a nginx-forwarder and the other one is the normal application container. I want to access to the app-container via oc.exe to get the jboss server.log. I executed the following command: oc exec <pod-name> cat <path-2-serverlog>/server.log <local path>/server.log But the default container is the nginx forwarder and therefore the directories included in are not existing.

Error Message:

Defaulting container name to nginx-jwt-forwarder. Use 'oc describe pod/<pod-name> -n <oc-project>' to see all of the containers in this pod. cat: <path-2-serverlog/server.log: No such file or directory cat: c:/temp/server.log: No such file or directory command terminated with exit code 1

How can I switch to the app-container instead of the default nginx?

Laurel
  • 5,965
  • 14
  • 31
  • 57

1 Answers1

1

In this case oc exec inherits its params from kubectl exec.
Just run your command as follows.
oc exec $pod -c $container_name $command

For example.
oc exec mypod -c ruby-container date
https://www.mankier.com/1/oc-exec

Olesya Bolobova
  • 1,573
  • 1
  • 10
  • 21