大网数据广告活动
服务器运维问答

TFTP-hpa not logging in a docker container

· 52CE 我爱测

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 anyon…

问题原文

原帖链接 · 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/log inside the container by adding -v /dev/log:/dev/log to your docker run command line; this will make log messages from tftpd in 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 busybox and then run busybox syslogd before you start the tftpd service. For example, your CMD might look like:

    CMD ["sh", "-c", "busybox syslogd; in.tftpd -Lvvv"]
    

    In this case, the logs would be visible in /var/log/messages inside 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 syslogd write 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。