

Docker provides the exec -it command to allow you to run any command inside any running Docker process. & ln -sf /dev/stderr /var/log/nginx/error.logīut, if you want to check out specific files inside a container, you can do so. RUN ln -sf /dev/stdout /var/log/nginx/access.log It does this with a symlink from /dev/stdout to the log file, and you can set up something similar for your containers.

For example, the default NGINX container is set up to send its Docker logs to STDOUT to make log checking easier. Viewing Logs From Apps Inside Containersĭepending on the container, this might not be necessary. Accessing logs like this is still possible from the host side through Docker. Many apps have their own dedicated logging systems, which often log to files like /var/log/nginx/access.log. However, one thing you’ll notice is that this is STDOUT and STDERR, which is useful for lots of things, but only shows you the console output of the entrypoint specified by “CMD” in the Docker file. If you’re using Docker Compose, you can use the log command from that to view all logs easily: docker-compose logs You can also -tail the file, or use -timestamps to display the log time, or use -until and -since to filter based on time. In this blog post, you have learned to truncate (clear) log files of a Docker container.Here, the -f flag will keep the prompt open and “follow” any new entries in the file. You can quickly truncate the docker log files using one of the above options. truncate -s 0 /var/lib/docker/containers/*/*-json.log

Use inspect option to find the log file name and location of a docker container.
