I have an application I am trying to move into a docker container. I have most things working, but the part of the application that requires elevated privileges (to use socket and configure network parameters) does not seem to be working.
What I've tried:
- Giving the
--privilegedflag - Giving the
--cap-add=NET_ADMINflag - Removing security options with
--security-opt apparmor=unconfined --security-opt seccomp=unconfined - Adding user groups and sudo in the Dockerfile
- Using the
--net=host \option. - Adding my user to the docker group
This is the error I'm getting:
Process Process-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/app/support_files/wizard_configuration_routines.py", line 781, in find_device
device_list = scan_subnet('192.168.30.0/24',g_interface)
File "/app/support_files/wizard_configuration_routines.py", line 757, in scan_subnet
answered, unanswered = scapy.arping(subnet,verbose=False,iface=g_interface)
File "/usr/local/lib/python3.9/site-packages/scapy/layers/l2.py", line 890, in arping
ans, unans = srp(
File "/usr/local/lib/python3.9/site-packages/scapy/sendrecv.py", line 687, in srp
s = iface.l2socket()(promisc=promisc, iface=iface,
File "/usr/local/lib/python3.9/site-packages/scapy/arch/linux.py", line 484, in __init__
self.ins = socket.socket(
File "/usr/local/lib/python3.9/socket.py", line 232, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted
Below are the relevant files
Dockerfile
# Slim version of Python
FROM python:3.9-slim
# Download Package Information
RUN apt update -y
# Install Tkinter
RUN apt install tk -y
# Install fontconfig
RUN apt install fontconfig -y
# Install Pillow
RUN python3 -m pip install Pillow
RUN python3 -m pip install ouster-sdk
RUN python3 -m pip install scapy
RUN python3 -m pip install customtkinter
RUN apt install net-tools -y
RUN fc-cache -f -v
# Commands to run Tkinter application
CMD ["/app/SCOT_wizard.py"]
ENTRYPOINT ["python3"]
build.sh
sudo docker build -t tkinter_in_docker .
run.sh
sudo docker run -u=$(id -u $USER):$(id -g $USER) \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v $(pwd)/app:/app \
-v $(pwd)/logs:/logs \
-v $(pwd)/records:/records \
-v $(pwd)/fonts:/.fonts\
-w /app \
--privileged \
--net=host \
--rm \
tkinter_in_docker
from Unable to connect to socket in docker: PermissionError: [Errno 1] Operation not permitted
No comments:
Post a Comment