Bootstrap FreeKB - OpenShift - View pod logs using the oc logs command
OpenShift - View pod logs using the oc logs command

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The oc get pods command can be used to list the pods in the currently selected project.

~]# oc get pods
NAME         READY   STATUS     RESTARTS  AGE
foo-9mzm2    1/1     Running    0         8d
foo-vmzmz    1/1     Running    0         8d
bar-pflxc    1/1     Running    0         8d

 

The oc logs pod/<pod name> command can be used to view a pods log.

oc logs pod/foo-9mzm2

 

The output can be pipe to the tail command to only view the last 10 entries in the log.

oc logs pod/foo-9mzm2 | tail

 

The -f or --follow option can be used to stream the log in real time.

oc logs -f pod/foo-9mzm2

 

The -p or --previous flag can be used to see previous logs.

oc logs -p pod/foo-9mzm2

 

The -s or --since option can be used to only display logs in the last x seconds, x mintues, or x days.

oc logs -p pod/foo-9mzm2 --since=24h

 

Or, you could SSH onto node server1.example.com. Switch to the root user account.

sudo -i

 

The container will contain the POD log, like this.

ll /var/lib/docker/containers/9db83c50f717fd4a42e98397aa8bc05442c6794bbe7e76337bb601f6d6197d1d


-rw-r-----. 1 root root 233245 Jul 22 15:23 9db83c50f717fd4a42e98397aa8bc05442c6794bbe7e76337bb601f6d6197d1d-json.log
drwx------. 2 root root      6 Jul 21 17:20 checkpoints
-rw-r--r--. 1 root root  12137 Jul 21 17:20 config.v2.json
-rw-r--r--. 1 root root   2668 Jul 21 17:20 hostconfig.json
drwxr-xr-x. 8 root root    220 Jul 21 17:20 secrets

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 971c73 in the box below so that we can be sure you are a human.