启用了重启始终选项的Docker卷

时间:2017-03-22 15:23:33

标签: ubuntu docker docker-compose mounted-volumes

我有问题配置我的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文件是一个文件,而不是目录。如果我说在目录容器中安装卷运行良好,这可能会有所帮助。请帮助,搜索已经整个互联网,没有任何真正的工作。感谢

1 个答案:

答案 0 :(得分:1)

检查/ home是否由encfs加密。默认情况下,Ubuntu会在安装过程中配置此功能。

运行此命令:mount|grep home并检查输出是否有type encfs之类的内容。