Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: tail log file without hanging

I have a JBoss, when it starts and deploys, it writes log file into /var/log/jboss-as/console.log line by line.

I want to print the log file line by line when I launch the container, so I can debug easily.

I tried something like:

RUN tail -F  /var/log/jboss-as/console.log

in my Dockerfile. But it failed to build the image. It hanged and nothing happened after.

How can I print the log file without hanging?

Thanks.

like image 689
hawarden_ Avatar asked Oct 29 '25 17:10

hawarden_


2 Answers

You shouldn't include tail -f inside docker file.

You can run:

docker exec -it jboss tail -f /var/log/jboss-as/console.log

after you've started your container.

like image 78
anubhava Avatar answered Oct 31 '25 08:10

anubhava


Start your container with a command like:

docker run -it imagename

It should print any STDOUT to your console. Then you can use Ctrl-P Ctrl-Q to exit.

like image 26
Patrick Avatar answered Oct 31 '25 08:10

Patrick