Run a subprogram of a Python program as root?

I have a Dockerfile (appended) that installs a bunch of modules and runs a Python program. You can see a Github repo at: GitHub - richb-hanover/zoomready at add-dockerfile

One of the modules is ping3, which sends ping packets. When called, it fails since (it appears) that it needs to be run as root to send pings. When I invoke it manually, I see this result (second example uses -u 0 to run as root):

docker exec -it whatever-docker-name /bin/bash # "ping3" gives Permission error

docker exec -u 0 -it whatever-docker-name /bin/bash # "ping3" works as expected

My questions:

  • How can I invoke the Python program so that it passes sufficient permissions to the ping3 module?

  • Is it possible to “bless” the ping3 program so that it runs “as root” without its caller being root?

  • Are there other possibilities to make ping3 work?

Many thanks.

Note: This question started life as Can't ping from container to external host (macOS), but it has evolved from a “Mac problem” to a “Permissions problem”, so I thought I’d start a new topic.

# Slim version of Python
FROM python:3.8.12-slim

# Download Package Information
RUN apt-get update -y

# Install Tkinter
RUN apt-get install tk -y

# Install Python modules
RUN pip install --no-cache-dir -U numpy
RUN pip install --no-cache-dir -U psutil
RUN pip install --no-cache-dir -U ping3
RUN pip install --no-cache-dir -U cloudflarepycli

# Commands to run Tkinter application
CMD ["/src/"]
ENTRYPOINT ["python3"]