1panel报错flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file解决

本文最后更新于 2023年9月17日。

1panel安装openresty的时候报错

报错内容如下:

mount /opt/1panel/apps/openresty/openresty/conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

解决办法

这是1panel的bug,新版已经修复。
1pctl restart重启1panel,卸载openresty后在应用列表界面点击刷新应用列表后重新安装就正常了,新版修复了这个问题。

探索过程

在找到解决办法前,找出错的原因

分析

这种错误一般由于主机上没有相应的文件,docker在创建的时候把文件路径当成文件夹创建导致docker挂在同步数据的时候文件夹和文件类型对应不上而报错。

所以准备修改文件映射方式

改变成我经常用的文件卷映射方式就可以了

services:
openresty:
container_name: ${CONTAINER_NAME}
deploy:
resources:
limits:
cpus: ${CPUS}
memory: ${MEMORY_LIMIT}
hostname: ${CONTAINER_NAME}
image: openresty/openresty:1.21.4.2-0-focal
labels:
createdBy: Apps
network_mode: host
restart: always
volumes:
- openrestyConf:/usr/local/openresty/nginx/conf
- openrestyLog:/var/log/nginx
- openrestyWww:/www
- openrestyHtml:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
volumes:
openrestyConf: null
openrestyHtml: null
openrestyLog: null
openrestyWww: null
version: "3.7"

这种方式docker能正常拷贝文件

这种方式还是有点问题,因为毕竟对默认的方式做了修改,可能影响一些其他功能。

更新之前创建的yml是这样的

version: '3'
services:
openresty:
image: openresty/openresty:1.21.4.2-0-focal
container_name: ${CONTAINER_NAME}
restart: always
network_mode: host
volumes:
- ./conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./conf/fastcgi_params:/usr/local/openresty/nginx/conf/fastcgi_params
- ./conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf
- ./log:/var/log/nginx
- ./conf/conf.d:/usr/local/openresty/nginx/conf/conf.d/
- ./www:/www
- ./root:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
labels:
createdBy: "Apps"

更新之后创建的文件是这样的

services:
openresty:
container_name: ${CONTAINER_NAME}
deploy:
resources:
limits:
cpus: ${CPUS}
memory: ${MEMORY_LIMIT}
image: openresty/openresty:1.21.4.2-0-focal
labels:
createdBy: Apps
network_mode: host
restart: always
volumes:
- ./conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./conf/fastcgi_params:/usr/local/openresty/nginx/conf/fastcgi_params
- ./conf/fastcgi-php.conf:/usr/local/openresty/nginx/conf/fastcgi-php.conf
- ./log:/var/log/nginx
- ./conf/conf.d:/usr/local/openresty/nginx/conf/conf.d/
- ./www:/www
- ./root:/usr/share/nginx/html
- /etc/localtime:/etc/localtime
version: "3"