Because colleagues in the company need Nginx log standard output, that is, processing through the console, we need to write the log to the file first:
There are two ways to deal with it: 1. Create a host path and then mount it to the nginx log path in the container: docker run --name docker_nginx -d -p 80:80\ -v /var/log/nginx/log:/var/log/nginx\ --!-v: Mount the log directory 2. The second is to land in the log file and then direct to standard output: RUN \ ln -sf /dev/stdout /var/log/nginx/access.log && \ ln -sf /dev/stderr /var/log/nginx/error.log I heard the second one is better! ! ! This solves the log problem! Supplementary knowledge: Custom docker nginx image without container log output It just so happens that I need to customize an nginx image for my work environment. After generating it, I found that the container has no relevant nginx log output FROM env_centos:latest COPY nginx.repo /etc/yum.repos.d/ # Note that the log output must be redirected to stdout, otherwise the container log output cannot be seen RUN \ yum -y install nginx httpd-tools && \ mkdir -p /data/nginx_conf/upstream && \ mkdir -p /data/nginx_conf/vhosts && \ rm -f /etc/nginx/conf.d/default.conf && \ ln -sf /dev/stdout /var/log/nginx/access.log && \ > These two lines are the key. Of course, this should match your nginx configuration file. Don't copy it. ln -sf /dev/stderr /var/log/nginx/error.log > These two lines are the key. COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 #EXPOSE 443 CMD ["nginx", "-g", "daemon off;"] The final effect is as follows #docker exec test123 ls -l /var/log/nginx/ lrwxrwxrwx 1 root root 11 Dec 29 10:51 access.log -> /dev/stdout lrwxrwxrwx 1 root root 11 Dec 29 10:51 error.log -> /dev/stderr The above detailed explanation of the processing of the three Docker Nginx Logs is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Implementation of vue+drf+third-party sliding verification code access
>>: Markup Language - Print Style Sheets
This article introduces the development environme...
Use JS timer to make an element to make a method ...
Table of contents Basic HTML structure Generate s...
Table of contents Preface 1. scp usage 2. Use sft...
I have never been able to figure out whether the ...
Table of contents Intro Nginx Dockerfile New conf...
Problem background: There is a requirement to tak...
environment: 1. Windows Server 2016 Datacenter 64...
JSON is a lightweight data exchange format that u...
Table of contents 1. Introduction: 2. Docker: 1 C...
This article mainly introduces an example of impl...
How to view files in a docker image 1. If it is a...
Table of contents Preface Input box component lay...
There is no solution for Chinese input method und...
When using MYSQL, triggers are often used, but so...