docker 部署FACT遇见各种Permission denied
fact_docker-fact-frontend-1 | [2024-02-27 02:17:03][install][ERROR]: Failed to run docker-compose -f /opt/FACT_core/src/install/radare/docker-compose.yml up -d:
fact_docker-fact-frontend-1 | Traceback (most recent call last):
fact_docker-fact-frontend-1 | File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 703, in urlopen
fact_docker-fact-frontend-1 | httplib_response = self._make_request(
fact_docker-fact-frontend-1 | File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 398, in _make_request
fact_docker-fact-frontend-1 | conn.request(method, url, **httplib_request_kw)
fact_docker-fact-frontend-1 | File "/usr/lib/python3.8/http/client.py", line 1256, in request
fact_docker-fact-frontend-1 | self._send_request(method, url, body, headers, encode_chunked)
fact_docker-fact-frontend-1 | File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
fact_docker-fact-frontend-1 | self.endheaders(body, encode_chunked=encode_chunked)
fact_docker-fact-frontend-1 | File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
fact_docker-fact-frontend-1 | self._send_output(message_body, encode_chunked=encode_chunked)
fact_docker-fact-frontend-1 | File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
fact_docker-fact-frontend-1 | self.send(msg)
fact_docker-fact-frontend-1 | File "/usr/lib/python3.8/http/client.py", line 951, in send
fact_docker-fact-frontend-1 | self.connect()
fact_docker-fact-frontend-1 | File "/usr/local/lib/python3.8/dist-packages/docker/transport/unixconn.py", line 30, in connect
fact_docker-fact-frontend-1 | sock.connect(self.unix_socket)
fact_docker-fact-frontend-1 | PermissionError: [Errno 13] Permission denied
由于之前已在测试服务器中正常部署相关服务,有了一定踩坑经验,使用docker inspect比较两个服务容器发现其中同一个容器有以下问题:未正常运行的容器中的GroupAdd映射为null
此处是通过环境变量传递到docker-compose.yaml文件中的,排查是否环境变量未正确配置:发现只有group_add配置的${FACT_DOCKER_DOCKER_GID}未正确映射到容器中,其他映射正常。至此可以确定此次失败为:docker-compose配置的group_add未生效;
创建一个简单容器确认问题来源,可以使用id来查看当前用户所属组信息
docker-compose.yaml文件实例
services:
my-service:
image: alpine:latest
command: /bin/sh -c "echo Hello, World!"
group_add:
- '380'
在docker-compose.yaml文件所处目录执行命令构建容器
docker-compose up
容器构建成功后查看用户组是否添加成功,可以看到同样未添加成功,在另一台服务器中构建同样的容器发现另一条服务器中用户组添加成功!!!
分别使用docker-compose -v查看两个服务器版本信息,发现未正常添加用户组配置的版本为V2.2.2 正常添加的版本为V2.24.5,尝试将服务器docker-compose版本升级至V2.24.5后查看是否问题解决:可以发现将docker-compose 版本升级至V2.24.5后成功解决该问题。
附:下载地址(可科学上网后scp至服务器):https://github.com/docker/compose/releases/download/v2.24.5/docker-compose-linux-x86_64
#查看docker-compose版本
docker-compose -v
Docker Compose version v2.24.5#运行容器
docker-compose up
[+] Running 1/1
✔ Container zhang-my-service-1 Created 0.2s
Attaching to my-service-1
my-service-1 | Hello, World!
my-service-1 exited with code 0#查看容器信息
docker inspect 9c16644269aa