docker挂载文件自动创建目录而非文件问题

docker挂载文件自动创建目录而非文件问题

环境:centos7

安装frps

yun update 无法解决

1
2
3
4
5
6
7
8
9
10
docker pull snowdreamtech/frps
#start frps
mkdir -p /volumes/etc/frp/
cd /volumes/etc/frp/
touch frps.ini # 不要让docker 挂载的时候创建否则默认创建的是目录而非文件
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:75: mounting "/volumes/etc/frp/frps.ini" to rootfs at "/etc/frp/frps.ini" caused: mount through procfd: 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.
docker run --restart=always --network host -d -v /volumes/etc/frp/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps
# 确认查看容器对应的文件内容:
subdomain_host = nas.runrab.com
docker exec -it busybox cat /tmp/text.txt

直接先不挂载容器 然后将需要的东西从容器中cp出来
然后再挂载

解决安装错误方法

1
2
3
4
5
6
7
8
docker run --restart=always --network host -d -v /volumes/etc/frp/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c5a4f77b3bf5 snowdreamtech/frps "/bin/sh -c '/usr/bi…" 5 minutes ago Created frps
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
docker rm c23400eeec94
c23400eeec94