解决在Docker中运行Python程序出现Operation not permitted
问题
在raspberryPi运行minirplus/speedtest-cli:arm
1 |
docker run -it --rm minirplus/speedtest-cli:arm --no-upload --server 3633 |
出现
1 2 3 |
Retrieving speedtest.net configuration... Cannot retrieve speedtest configuration ERROR: [Errno 1] Operation not permitted |
调查
进入基础镜像 docker run -it --rm python:rc-alpine3.13 /bin/sh
执行 pip install speedtest-cli
出现
1 2 3 4 5 6 7 8 |
Traceback (most recent call last): File "/usr/local/bin/pip", line 5, in <module> from pip._internal.cli.main import main File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 4, in <module> import logging File "/usr/local/lib/python3.10/logging/__init__.py", line 57, in <module> _startTime = time.time() PermissionError: [Errno 1] Operation not permitted |
结论
Container容器的权限不够,有可能是Docker属于非Root用户。
解决
不修改docker权限,直接在docker运行时参数加上 --privileged 即可解决问题
1 |
docker run -it --rm --privileged minirplus/speedtest-cli:arm --no-upload --server 3633 |
–privileged Give extended privileges to this container
Done!
There are no comments yet