【问题标题】:Docker volume with restart always option enabled启用了始终重启选项的 Docker 卷
【发布时间】:2017-03-22 15:23:32
【问题描述】:

我在配置我的 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 文件是一个文件,而不是目录。如果我说将卷安装到作为目录的容器中效果很好,也许会有所帮助。请帮忙,已经搜索了整个互联网,但没有任何效果。谢谢

【问题讨论】:

    标签: ubuntu docker docker-compose mounted-volumes


    【解决方案1】:

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

    运行这个命令:mount|grep home 并检查输出是否有type encfs 或类似的东西。

    【讨论】:

    • 是的,当我将文件源更改为 /etc/file 时,它​​确实有 type ecryptfs 一切正常
    猜你喜欢
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多