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
Table of contents Algorithmic Strategy Single-nod...
Table of contents Mixin Mixin Note (duplicate nam...
Normally, when a deadlock occurs, the connection ...
Click the button to turn the text into an input b...
1. Text formatting: This example demonstrates how...
This article example shares the specific code of ...
This article example shares the specific code of ...
Table of contents definition Constructor bodies a...
1. MySQL master-slave asynchrony 1.1 Network Dela...
When any project develops to a certain complexity...
When using Docker in a production environment, da...
Note: sg11 Our company only supports self-install...
Vue+Openlayer uses modify to modify elements. The...
Preface In the previous article Two data types in...
1. Add the ul tag in the body first <!-- Unord...