我在配置我的 docker-compose 文件时遇到问题,docker 可以在重新启动时重新启动容器(我的操作系统是 Ubuntu 16.04)。问题不在于我传入restart: always
它时,而是当我的容器需要一些基于卷的文件时(例如 ssl-cert 到 nginx 中)。我的代码(在 docker-compose.yml 中):
php:
entrypoint: ["wait-for-it", "dockerhost:3306", "-t", "0", "--", "/install.sh"]
environment:
- ENVIRONMENT=prod
volumes:
- ${FILE}:/file
- /code
env_file:
- prod.env
restart: always
当我自己启动时,一切都很好。然后我正在检查它是否会在重新启动后工作。但是,不,它不起作用,docker-compose ps
给出:
Name Command State Ports
-----------------------------------------------------------------------
panel_php_1 wait-for-it dockerhost:330 ... Exit 127
通过执行docker inspect panel_php_1
它会回显错误:
"Error": "oci runtime error: container_linux.go:247: starting container process caused \"process_linux.go:359: container init caused \\\"rootfs_linux.go:54: mounting \\\\\\\"/home/mblocinski/hehe.txt\\\\\\\" to rootfs \\\\\\\"/var/lib/docker/aufs/mnt/d746adf311098a9e2ffc27d9447a3e448ecfb9081ff4757704c24ec51ef9053e\\\\\\\" at \\\\\\\"/var/lib/docker/aufs/mnt/d746adf311098a9e2ffc27d9447a3e448ecfb9081ff4757704c24ec51ef9053e/file\\\\\\\" caused \\\\\\\"not a directory\\\\\\\"\\\"\"\n: 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"
和坐骑:
"Mounts": [
{
"Type": "bind",
"Source": "/home/mblocinski/hehe.txt",
"Destination": "/file",
"Mode": "rw",
"RW": true,
"Propagation": ""
}
]
我确定 hehe.txt 文件是一个文件,而不是目录。如果我说将卷安装到作为目录的容器中效果很好,也许会有所帮助。请帮忙,已经搜索了整个互联网,但没有任何效果。谢谢