docker-compose.yml示例文件:
version: '3'
services:
oceanmind_ai:
image: aarch64_pdf2word:v1.4
container_name: oceanmind_ai
restart: always
entrypoint: sh /home/rhino/oceanmind_ai/start.sh
environment:
- LANG=zh_CN.utf8
- TZ=Asia/Shanghai
ports:
- "7032:7031"
volumes:
- ./config/oceanmind_ai20240301:/home/rhino/oceanmind_ai
- /etc/hosts:/etc/hosts
- ./test20240305.txt:/home/rhino/test20240305.txt
- ./service_check.py:/home/rhino/oceanmind_ai/service_check.py
networks:
- sinovatio
########## shared network ##########
networks:
sinovatio:
external: false
########## shared network ##########
情形假设:
-
宿主机和容器均存在该文件:
/etc/hosts:/etc/hosts:文件会被同步 -
宿主机存在,容器不存在:
./test20240305.txt:/home/rhino/test20240305.txt:容器内会创建该文件 -
宿主机不存在,容器存在
./service_check.py:/home/rhino/oceanmind_ai/service_check.py:貌似不被允许Error response from daemon: OCI runtime create failed: container_linux.go:318: starting container process caused "process_linux.go:378: container init caused \"rootfs_linux.go:60: mounting \\\"/home/xsg/docker_manage/service_check.py\\\" to rootfs \\\"/home/data01/docker/overlay2/5a286c8dd3f877225a425a29d52081208e286a6f3f09d11118c13cb490645bb0/merged\\\" at \\\"/home/data01/docker/overlay2/5a286c8dd3f877225a425a29d52081208e286a6f3f09d11118c13cb490645bb0/merged/home/rhino/oceanmind_ai/service_check.py\\\" caused \\\"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这个错误是因为你试图将一个目录挂载到一个文件上,或者将一个文件挂载到一个目录上。请检查指定的主机路径是否存在并且是预期的类型。
-
宿主机和容器都被存在
两端均会自动创建文件夹,注意,是文件夹,而不是目录,即时该路径有后缀
./test20240305.txt:/home/rhino/test20240305.txt