问题原文
原帖链接 · R Tweed · CC BY-SA 3.0
I'm running tftpd-hpa on the ubuntu:16.04 base image. When I run this on a full distro it logs fine but inside a docker container there aren't any logs. It seems to be trying to log to /var/log/syslog which is missing. Does anyone have any suggestions for how I can get some logs from this?
The verbosity is set to 4 which gives suitable verbose output on the full Ubuntu 16.04 install but nothing in the container.
Thanks
已采纳解答
原帖链接 · larsks · CC BY-SA 3.0
tftpd does not write to log files on it's own. Rather, it logs via syslog (it opens /dev/log and writes messsages there, which are collected by some sort of logging daemon and then dispatched to files based on its configuration).
Inside a typical container there is no logging daemon, so nothing is listening on /dev/log and your log messages simply disappear.
If you want to see those logs when running tftpd inside a container, you will need to have something listen on /dev/log. You have several options:
You can mount your host's
/dev/loginside the container by adding-v /dev/log:/dev/logto yourdocker runcommand line; this will make log messages fromtftpdin the container appear in your host's/var/log/...files (final destination dependent on your syslog configuration, but generally something like/var/log/messages).You can run a minimal syslog service in the container and it log to a file. For example, you could install
busyboxand then runbusybox syslogdbefore you start thetftpdservice. For example, yourCMDmight look like:CMD ["sh", "-c", "busybox syslogd; in.tftpd -Lvvv"]In this case, the logs would be visible in
/var/log/messagesinside the container.Instead of writing logs to a file, you could redirect them to the container's stdout. If you modify the above command to have
busybox syslogdwrite to stdout, like this...CMD ["sh", "-c", "busybox syslogd -n -O /dev/stdout & in.tftpd -Lvvv"]...then you will see logs on your container's console, where they will also be collected by Docker and made available via
docker logs.
This isn't an exhaustive list of solutions, but hopefully it's enough to point you towards a solution.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
