Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在Docker中装入文件 错误描述_Docker_Permissions_Docker Compose_Mount - Fatal编程技术网

无法在Docker中装入文件 错误描述

无法在Docker中装入文件 错误描述,docker,permissions,docker-compose,mount,Docker,Permissions,Docker Compose,Mount,我无法在Vagrant或Docker中装载文件,因此这似乎是由某种权限错误引起的问题。 我的操作系统是ubuntu18.04lts(仿生海狸),据我所知,我没有运行任何访问控制模块,如SELinux 与流浪汉有关的错误讨论可在另一个问题中找到: Docker疑难解答 我无法使用Docker compose将文件装载到Docker容器中,我正在尝试构建: 我将docker compose文件中的卷设置为: volumes: - ${PWD}/assets/master/etc/supervi

我无法在Vagrant或Docker中装载文件,因此这似乎是由某种权限错误引起的问题。
我的操作系统是
ubuntu18.04lts(仿生海狸)
,据我所知,我没有运行任何访问控制模块,如
SELinux

与流浪汉有关的错误讨论可在另一个问题中找到:

Docker疑难解答 我无法使用Docker compose将文件装载到Docker容器中,我正在尝试构建:

我将
docker compose
文件中的卷设置为:

volumes:
  - ${PWD}/assets/master/etc/supervisor:/etc/supervisor
  - ${PWD}/assets/master/etc/salt:/etc/salt
  - ${PWD}/assets/master/var/cache/salt:/var/cache/salt
  - ${PWD}/assets/master/var/log/salt:/var/log/salt
  - ${PWD}/assets/master/srv:/srv
然而,我在运行docker compose up时得到了这个输出:

Creating network "saltstack_default" with the default driver
Creating salt_image
Creating salt
Creating minion
Attaching to salt, minion, salt_image
salt      | Error: could not find config file /etc/supervisor/supervisord.conf
salt      | For help, use /usr/bin/supervisord -h
salt exited with code 2
salt_image exited with code 0
minion    | [ERROR   ] DNS lookup of 'salt' failed.
minion    | [ERROR   ] Master hostname: 'salt' not found. Retrying in 30 seconds
docker inspect
检查集装箱显示正确配置:

   "Mounts": [
        {
            "Type": "bind",
            "Source": "/somedir/saltstack/assets/master/etc/salt",
            "Destination": "/etc/salt",
            "Mode": "rw",
            "RW": true,
            "Propagation": "rprivate"
        },
        {
            "Type": "bind",
            "Source": "/somedir/saltstack/assets/master/var/cache/salt",
            "Destination": "/var/cache/salt",
            "Mode": "rw",
            "RW": true,
            "Propagation": "rprivate"
        },
        {
            "Type": "bind",
            "Source": "/somedir/saltstack/assets/master/etc/supervisor",
            "Destination": "/etc/supervisor",
            "Mode": "rw",
            "RW": true,
            "Propagation": "rprivate"
        },
        {
            "Type": "bind",
            "Source": "/somedir/saltstack/assets/master/var/log/salt",
            "Destination": "/var/log/salt",
            "Mode": "rw",
            "RW": true,
            "Propagation": "rprivate"
        },
        {
            "Type": "bind",
            "Source": "/somedir/saltstack/assets/master/srv",
            "Destination": "/srv",
            "Mode": "rw",
            "RW": true,
            "Propagation": "rprivate"
        }
但进入容器(使用另一个entrypoint命令)时,显示应该装入的文件丢失:

[root@salt /]# ll /etc/supervisor
total 0
[root@salt /]# ll /etc/salt
total 0
[root@salt /]# ll /var/cache/salt
total 0
[root@salt /]# ll /var/log/salt
total 0
[root@salt /]# ll /srv
total 0
结论 在复制文件时,我的本地计算机上似乎出现了一些非常混乱的情况,可能与我的用户如何配置以及如何将文件装载到虚拟机和容器中有关。
如果有人能解释一下,我会很感激的

更新 更新1 我怀疑这是我将要删除的
/var/lib/docker
中的旧内容的问题,但在此之前,我遇到了另一个错误,可能是某种权限错误:

> cat docker-compose.yml 
# based on https://docs.docker.com/samples/library/nginx/#using-environment-variables-in-nginx-configuration
version: '2'

services:
  web:
    image: nginx
    volumes:
     - ./testfile.txt:/etc/nginx/
    ports:
     - "8080:80"
    environment:
     - NGINX_HOST=foobar.com
     - NGINX_PORT=80
    command: /bin/bash -c "nginx -g 'daemon off;'"

> docker-compose up
Creating network "docker_compose-mounting_issue_default" with the default driver
Creating docker_compose-mounting_issue_web_1 ... error

ERROR: for docker_compose-mounting_issue_web_1  Cannot start service web: b'OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \\"rootfs_linux.go:58: mounting \\\\\\"/home/.../troubleshoot/docker_compose-mounting_issue/testfile.txt\\\\\\" to rootfs \\\\\\"/var/lib/docker/aufs/mnt/580b79241399e838c67b74021ecf2597aade5f1711811f4ab5c9c7bbcd188449\\\\\\" at \\\\\\"/var/lib/docker/aufs/mnt/580b79241399e838c67b74021ecf2597aade5f1711811f4ab5c9c7bbcd188449/etc/nginx\\\\\\" 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'

ERROR: for web  Cannot start service web: b'OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \\"rootfs_linux.go:58: mounting \\\\\\"/home/.../troubleshoot/docker_compose-mounting_issue/testfile.txt\\\\\\" to rootfs \\\\\\"/var/lib/docker/aufs/mnt/580b79241399e838c67b74021ecf2597aade5f1711811f4ab5c9c7bbcd188449\\\\\\" at \\\\\\"/var/lib/docker/aufs/mnt/580b79241399e838c67b74021ecf2597aade5f1711811f4ab5c9c7bbcd188449/etc/nginx\\\\\\" 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'
ERROR: Encountered errors while bringing up the project.
更新2
因此,我删除了
/var/lib/docker/
中的所有内容,现在它可以正常工作,挂载我的文件。它可能在什么地方坏了。我遇到的另一个建议是授予目录的权限,
chmod 777
似乎对一些用户有所帮助,但我认为这并不安全。

用户拥有什么文件夹权限(您登录的文件夹运行docker compose命令),如果该用户是root用户,或者该用户有权访问文件夹,请将${PWD}更改为文件夹的相对/绝对路径(您要装入容器的路径)。 docker compose无法理解${PWD}env变量

如果你想骑自行车

${PWD}/assets/master/etc/supervisor:/etc/supervisor

应该是

/资产/船长/etc/主管:/etc/主管


我的一位同事建议这可能是由AUFS存储驱动程序引起的,我将对此进行进一步调查。PWD是在
/vagrant
中还是在
nfs
共享卷中?它可能是AppArmor吗?在
dmesg
的输出中是否有任何
apparmor=“DENIED”
行?能否提供
docker info
docker version
的输出,以及
docker inspect
的完整输出?TarunLalwani Vagrant与此docker构建无关;我没有看到关于apparmor的任何消息;gesellix:已更改,但仍然是相同的问题,可能与路径无关。@PetrusK。能否添加文件夹结构以及从何处运行docker命令。!