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

Trying to run heplify as non-root, with cap_add in a container #273

Open
TheQue42 opened this issue Jan 16, 2024 · 7 comments
Open

Trying to run heplify as non-root, with cap_add in a container #273

TheQue42 opened this issue Jan 16, 2024 · 7 comments

Comments

@TheQue42
Copy link
Contributor

Hi,

My attempts at running heplify in a non-root docker container, adding capabilities with:

cap_add:
  - CAP_NET_ADMIN
  - CAP_NET_RAW
  - CAP_BPF
  - CAP_SYS_ADMIN

in docker-compose.

But I just get: Critical: setting af_packet handle: operation not permitted

Any pointers?

@TheQue42
Copy link
Contributor Author

It seems the binary will need RUN setcap cap_net_raw,cap_net_admin=eip heplify in the dockerfile, for the capabilities to be used when starting. Is this something that could be added to the default image build?

@lmangani
Copy link
Member

@TheQue42 absolutely, feel free to open a PR with the proposed changes and we'll go from there

@TheQue42
Copy link
Contributor Author

I'd love to, but since the "RUN setcap" command cant be run in the "FROM scratch" image you use now, we'd have to change the empty base image into a "real" image that contains setcap.

And I am not sure I am the one to decide which you want?

@lmangani
Copy link
Member

heplify will run fine in any image, the scratch choice was purely related to size and proving the static build.
Feel free to switch to alpine or any other viable image and we'll go from there.

@TheQue42
Copy link
Contributor Author

Seems like this works.

https://github.com/TheQue42/heplify/blob/master/docker/heplify/Dockerfile

I'll continue tomorrow :-)

@lmangani
Copy link
Member

It looks promising! let us know if you notice any other issues before we make this the new standard

@TheQue42
Copy link
Contributor Author

Super! My docker-compose with:

  heplify:
    image: sipcapture/heplify:latest
    user: 1000:1000
    cap_add:
      - CAP_NET_ADMIN
      - CAP_NET_RAW
    profiles:
      - homer
    command:
      ./heplify -e -hs ${HOMER_DST}:9060 -m SIP -dd -zf -l info
    network_mode: host
    restart: unless-stopped
    depends_on:
      - xyz

Will now work fine!

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

No branches or pull requests

3 participants