Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
Created September 26, 2014 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuart-warren/6eb9ab53a3bebc895c40 to your computer and use it in GitHub Desktop.
Save stuart-warren/6eb9ab53a3bebc895c40 to your computer and use it in GitHub Desktop.
Docker log to stdout
Sometimes you want your container to log to stdout, but the process can only write to a file.
e.g. nginx
Simply create a symlink from the logfile you are writing to, to /proc/self/fd/1 or write directly to it.
Example:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /proc/self/fd/1;
error_log /proc/self/fd/1 info;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
open_file_cache max=100;
}
daemon off;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment