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

Can't run hello_world.py on Ubuntu VM with Docker #5080

Open
aaguirre-rdit opened this issue Aug 14, 2024 · 0 comments
Open

Can't run hello_world.py on Ubuntu VM with Docker #5080

aaguirre-rdit opened this issue Aug 14, 2024 · 0 comments

Comments

@aaguirre-rdit
Copy link

Hello!

I am trying to deploy a BCC program with Docker. I am using hello_world.py as a reference but I am getting the following error:

bpf: Argument list too long. Program  too large (0 insns), at most 4096 insns
Traceback (most recent call last):
  File "./main.py", line 2, in <module>
    BPF(text='int kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\\n"); return 0; }').trace_print()
  File "/usr/lib/python3/dist-packages/bcc-0.31.0+7988a53e-py3.8.egg/bcc/__init__.py", line 488, in __init__
  File "/usr/lib/python3/dist-packages/bcc-0.31.0+7988a53e-py3.8.egg/bcc/__init__.py", line 1480, in _trace_autoload
  File "/usr/lib/python3/dist-packages/bcc-0.31.0+7988a53e-py3.8.egg/bcc/__init__.py", line 527, in load_func
Exception: Failed to load BPF program b'kprobe__sys_clone': Argument list too long

Current setup:
Ubuntu 20.04
AMD x64
BCC v0.31.0-1-g7988a53e
Kernel version 5.15

The BCC Python script and Dockerfile are as follows:

#!/usr/bin/python

from bcc import BPF

BPF(text='int kprobe__sys_clone(void *ctx) { bpf_trace_printk("Hello, World!\\n"); return 0; }').trace_print()

# Dockerfile
FROM alpine:3.8

RUN apk add --update \
    bash \
    bc \
    build-base \
    bison \
    flex \
    curl \
    elfutils-dev \
    linux-headers \
    make \
    openssl-dev \
    zip

WORKDIR /

COPY /init/fetch-linux-headers.sh /
RUN chmod +x fetch-linux-headers.sh
ENTRYPOINT [ "/fetch-linux-headers.sh" ]


FROM ubuntu:20.04 as build
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt install -y zip bison python3-pip build-essential cmake flex git libedit-dev \
libllvm7 llvm-7-dev libclang-7-dev python zlib1g-dev libelf-dev libfl-dev bpfcc-tools \
python3-setuptools \
linux-headers-$(uname -r) \
liblzma-dev arping netperf iperf

RUN git clone https://github.com/iovisor/bcc.git
RUN mkdir bcc/build
WORKDIR bcc/build
RUN cmake ..
RUN make
RUN make install
RUN cmake -DPYTHON_CMD=python3 .. 
RUN rm -rf /usr/lib/python3/dist-packages/bcc
WORKDIR /usr/sbin/

COPY main.py .
CMD ["python3", "./main.py"]

The Python script runs correctly when executed via the command line, but it gets an E2BIG error when running via Docker.
I am using the following docker command to run the image:
sudo docker run -it --privileged <image>

Is there any additional configuration on the Dockerfile or flag in the Docker command that I might be missing?

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

1 participant