跳转到内容
For the complete documentation index, see llms.txt. This page is also available as Markdown.

18.17.故障排除

18.17.1. 软件包升级与挂载的文件

Podman 使用 mount_nullfs(8) 将 /etc/resolv.conf 和 /etc/hosts 挂载到容器中。在 pkg(8) 操作期间,这些挂载可能导致错误,并出现类似 Cross-device link 的消息:

pkg: Fail to rename /etc/.pkgtemp.hosts.VeIDrHM0sKN5 -> /etc/hosts:Cross-device link

要避免此问题,请使用 --no-hosts 与 --dns 选项:

# podman run --no-hosts --dns 1.1.1.1 -it --rm \
    ghcr.io/freebsd/freebsd-runtime:15.1 /bin/sh

18.17.2. 检查网络

从 /usr/local/etc/containers/pf.conf.sample 中的防火墙规则开始。在容器内逐步测试连通性:

# podman run --no-hosts --dns 1.1.1.1 \
    --env ASSUME_ALWAYS_YES=1 \
    -it --rm \
    ghcr.io/freebsd/freebsd-runtime:15.1 \
    /bin/sh

# route show 1.1.1.1
   route to: 1.1.1.1
destination: default
    gateway: 10.88.0.1
  interface: eth0

# ping -c 3 10.88.0.1
PING 10.88.0.1 (10.88.0.1): 56 data bytes
64 bytes from 10.88.0.1: icmp_seq=0 ttl=64 time=0.083 ms
...

# ping -c 3 1.1.1.1
PING 1.1.1.1 (1.1.1.1): 56 data bytes
64 bytes from 1.1.1.1: icmp_seq=0 ttl=60 time=0.920 ms
...

# fetch -v http://1.1.1.1/
...

# pkg -dd bootstrap -r FreeBSD

如果 ping(8) 失败,请检查防火墙规则是否阻止了 ICMP。如果 fetch(1) 失败,请检查防火墙规则是否阻止了端口 80 和 443 上的 TCP。如果 pkg(8) 失败而 ICMP 和 TCP 正常,则可能是分片或 MTU 问题。将 set reassemble yes no-df 添加到 /etc/pf.conf 并重启防火墙。

要调试被阻止的数据包,请在 /etc/pf.conf 的所有 block 规则上启用 log,并在 pflog(4) 设备上使用 tcpdump(1):

18.17.3. MTU 一致性

确保主网络接口、容器网桥和容器自身的 MTU 值保持一致。MTU 值不匹配可能导致数据包分片和连接故障。

下例中,vtnet0 的 MTU 为 9000,而网桥和容器的 MTU 为 1500。一般应调整内部布局以与外部网络保持一致:

在容器内:

最后更新于