0

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,

Nijisha Kg
  • 541
  • 2
  • 7
  • 15

2 Answers2

1

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?

Community
  • 1
  • 1
user2915097
  • 30,758
  • 6
  • 57
  • 59
1

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
bpatel
  • 381
  • 1
  • 4