5

I want to read log from container with another container in same pod

i've tried approach that shared volume between two container so i mapping the log file to a shared volume from container 1 and read the log file from container 2 with the same shared volume

but how i can read the stdout directly ? especially in kubernetes and the same pods ?

  • You can access the stdout of containers with `kubectl logs `. For a specific container in the Pod `kubectl logs -c `. – weibeld Mar 09 '20 at 11:14
  • well, that condition if i check it in host.. but i want to check it from side container in same pod.. could we achieve that ? – Renaldi Yulvianda Mar 09 '20 at 11:17
  • Kubernetes stores the stdout and stderr of containers in some file on the node on which the Pod is running. Where exactly this is, depends on your configuration. See [these answers](https://stackoverflow.com/a/47916855/4747193). – weibeld Mar 09 '20 at 11:37
  • i think i don't configure that much, and where is the default path ?.. my issue is, i want to run a script in a container 2 to read stdout from container 1.. it'll be work or not ? – Renaldi Yulvianda Mar 09 '20 at 15:56

1 Answers1

0

You should share process namespace between these two containers and then tail the logs of a process in one container to another.

Read the k8s docs

lakshman.pasala
  • 565
  • 6
  • 16
  • 5
    This doesn't address the question. It sidesteps and suggests an alternate scenario. Also, don't link to something without including the relevant bits here, as linkrot will render this answer useless over time. – Finster Mar 10 '21 at 19:18