skip to Main Content

I have a spring-boot application running inside a docker container & its working fine. But the thing is application log file is empty inside the docker container.
In logback-spring.xml log path has been configured to /var/log.
When I go to /var/log directory inside the docker container, I can see log file has been created like "myservice.log"
but when I "cat" the file to see the content, that is completely empty.
Also when I execute

docker logs <container-id>

it returns nothing.

And also I checked the docker root directory in the server.

/apps/docker/containers/<container-id>/<container-id-json.log>

that is also empty.

my Dockerfile has the following structure.

From private-docker-repo/openjdk:11-jre-slim

WORKDIR /opt/services

COPY target/my-service-0.0.1-SNAPSHOT.jar /opt/services/my-service.jar

CMD java -Dspring.profiles.active=dev -Dserver.port=61016 -jar my-service.jar

EXPOSE 61016

What can be the reason for being the log file is empty here. Highly appreciate if anyone can point me out.

Edit – when I deploy the same jar using a linux systemd service logs are just writing fine. I want to know why the same jar not printing any logs inside the docker container

Thanks in advance..!

2

Answers


  1. Chosen as BEST ANSWER

    I solved this just by replacing the CMD command with ENTRYPOINT. Now the logs are printing just fine. I did some search on the difference between CMD and ENTRYPOINT but still I cant understand how that affect the logging of a container. So if anyone can add a comment what could be happened, that's great not only for me but for the other who will see this question in future.

    Thank you :)


  2. are you sure that your application running? Get into the docker container and check whether it’s running, seems to me it’s not started.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search