Docker 始终启用重新启动选项的卷
Docker volume with restart always option enabled
我在配置 docker-compose 文件时遇到问题,docker 可以在重启时重新启动容器(我的 OS 是 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 文件是一个文件,而不是目录。如果我说将卷安装到作为目录的容器中效果很好,那可能会有所帮助。请帮助,已经搜索了整个互联网,但没有任何效果。谢谢
检查 /home 是否被 encfs 加密。默认情况下 Ubuntu 在安装期间配置此功能。
运行 这个命令:mount|grep home
并检查输出是否有 type encfs
或类似的东西。
我在配置 docker-compose 文件时遇到问题,docker 可以在重启时重新启动容器(我的 OS 是 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 文件是一个文件,而不是目录。如果我说将卷安装到作为目录的容器中效果很好,那可能会有所帮助。请帮助,已经搜索了整个互联网,但没有任何效果。谢谢
检查 /home 是否被 encfs 加密。默认情况下 Ubuntu 在安装期间配置此功能。
运行 这个命令:mount|grep home
并检查输出是否有 type encfs
或类似的东西。