Nijisha Kg
Nijisha Kg

Reputation: 581

How can I take logs of a running docker container

I need to run the docker container with logs redirected to a file in a shared location. I searched a lot for but didn't a solution for this. what I tried is: Run the docker container first docker run --name sample -d -p 8083:8080 xxxxx.yyyy.zzz/test/test-application:latest

then I ran docker run -v /home/ubuntu/logs:/opt/logs sample but when i check /home/ubuntu/logs folder, nothing is there.

Can anyone help me on this?

Thanks in advance,

Upvotes: 0

Views: 260

Answers (2)

bpatel
bpatel

Reputation: 391

You need to mount your external directory where you want logs to be stored when running the container.

docker run --name sample -d -p 8083:8080 -v /home/ubuntu/logs:/opt/logs xxxxx.yyyy.zzz/test/test-application:latest

Upvotes: 1

user2915097
user2915097

Reputation: 32176

you redirect it with a command such as

docker logs sample > /home/ubuntu/logs

see also

Redirect application logs to docker logs

and

how to redirect docker logs to a single file?

Upvotes: 1

Related Questions