Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker run fail,Error with no such device #278

Closed
172226325 opened this issue Sep 28, 2023 · 1 comment
Closed

docker run fail,Error with no such device #278

172226325 opened this issue Sep 28, 2023 · 1 comment

Comments

@172226325
Copy link

【env】
mac os
【cmd】
docker build --tag ebpf_exporter --target ebpf_exporter_with_examples .
docker run --rm -it --privileged -p 9435:9435
ebpf_exporter --config.dir=examples --config.names=timers --debug
【result】
2023/09/28 00:41:16 Error attaching fanotify, using on-demand resolution instead: error calling fanotify_mark for "/sys/fs/cgroup": no such device
2023/09/28 00:41:16 libbpf [debug]: libbpf: loading examples/timers.bpf.o
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(3) tp_btf/timer_start, size 232, link 0, flags 6, type=1
2023/09/28 00:41:16 libbpf [debug]: libbpf: sec 'tp_btf/timer_start': found program 'timer_start' at insn offset 0 (0 bytes), code size 29 insns (232 bytes)
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(4) .reltp_btf/timer_start, size 48, link 27, flags 40, type=9
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(5) license, size 4, link 0, flags 3, type=1
2023/09/28 00:41:16 libbpf [debug]: libbpf: license of examples/timers.bpf.o is GPL
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(6) .maps, size 32, link 0, flags 3, type=1
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(17) .BTF, size 1317, link 0, flags 0, type=1
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(19) .BTF.ext, size 300, link 0, flags 0, type=1
2023/09/28 00:41:16 libbpf [debug]: libbpf: elf: section(27) .symtab, size 408, link 1, flags 0, type=2
2023/09/28 00:41:16 libbpf [debug]: libbpf: looking for externs among 17 symbols...
2023/09/28 00:41:16 libbpf [debug]: libbpf: collected 0 externs total
2023/09/28 00:41:16 libbpf [debug]: libbpf: map 'timer_starts_total': at sec_idx 6, offset 0.
2023/09/28 00:41:16 libbpf [debug]: libbpf: map 'timer_starts_total': found type = 1.
2023/09/28 00:41:16 libbpf [debug]: libbpf: map 'timer_starts_total': found key [8], sz = 8.
2023/09/28 00:41:16 libbpf [debug]: libbpf: map 'timer_starts_total': found value [8], sz = 8.
2023/09/28 00:41:16 libbpf [debug]: libbpf: map 'timer_starts_total': found max_entries = 1024.
2023/09/28 00:41:16 libbpf [debug]: libbpf: sec '.reltp_btf/timer_start': collecting relocation for section(3) 'tp_btf/timer_start'
2023/09/28 00:41:16 libbpf [debug]: libbpf: sec '.reltp_btf/timer_start': relo #0: insn #7 against 'timer_starts_total'
2023/09/28 00:41:16 libbpf [debug]: libbpf: prog 'timer_start': found map 0 (timer_starts_total, sec 6, off 0) for insn #7
2023/09/28 00:41:16 libbpf [debug]: libbpf: sec '.reltp_btf/timer_start': relo #1: insn #15 against 'timer_starts_total'
2023/09/28 00:41:16 libbpf [debug]: libbpf: prog 'timer_start': found map 0 (timer_starts_total, sec 6, off 0) for insn #15
2023/09/28 00:41:16 libbpf [debug]: libbpf: sec '.reltp_btf/timer_start': relo #2: insn #20 against 'timer_starts_total'
2023/09/28 00:41:16 libbpf [debug]: libbpf: prog 'timer_start': found map 0 (timer_starts_total, sec 6, off 0) for insn #20
2023/09/28 00:41:16 libbpf [warn]: libbpf: failed to find valid kernel BTF
2023/09/28 00:41:16 libbpf [warn]: libbpf: Error loading vmlinux BTF: -3
2023/09/28 00:41:16 libbpf [warn]: libbpf: failed to load object 'examples/timers.bpf.o'
2023/09/28 00:41:16 Error attaching exporter: error loading bpf object from "examples/timers.bpf.o" for config "timers": failed to load BPF object: no such process

Mac os seems not have /sys/fs/cgroup, so I read the steps of README, found the way that can run without any bind mounts, but errors above occur, how I can solve this?

@bobrik
Copy link
Contributor

bobrik commented Sep 28, 2023

libbpf: failed to find valid kernel BTF is the error. Docker for mac ships with a kernel that doesn't have BTF:

$ docker run --rm -it ubuntu:22.04 zcat /proc/config.gz | fgrep BTF | wc -l
       0

You are trying to run the timers example that requires it:

See libbpf docs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants