1

I have a Spring-Boot application that I have running in a Docker container. When I run the app standalone outside of the container, all the logs are written to stdout. I need to get the app stdout written to a file on my Docker container.

My docker-compose file looks like this:

version: "3.3"

services:
  meanwhileinhell:
    image: azul/zulu-openjdk-centos:latest
    container_name: "meanwhile-in-hell"
    restart: always
    volumes:
      - logfiles:/var/log/meanwhileinhell/
    ports:
      - 8091:8091
    networks:
      - default

volumes:
  logfiles:
    driver: local

networks:
  default:
    external:
      name: meanwhileinhell-network

I can get the directory specified to be created ok, but there is nothing in it. Can someone help me as to how to get this to write to file? I haven't been able to find anything on SO or general searching. docker logs -f <container-id> shows the same information I am looking to write.

MeanwhileInHell
  • 6,780
  • 17
  • 57
  • 106
  • 1
    Docker won’t do this on its own. You need to [configure an alternate log driver](https://docs.docker.com/config/containers/logging/configure/), or else set up your process to write to a file instead of (or in addition to) stdout, or run an external process that knows about the Docker internal log format. – David Maze Feb 19 '20 at 16:51
  • Thanks @DavidMaze, I'll look into that. – MeanwhileInHell Feb 19 '20 at 17:21

0 Answers0