Docker Bind Mount的内容未显示在容器内部

发布于 2025-02-07 10:18:15 字数 1433 浏览 1 评论 0原文

编辑:

RCLONE有一个安装在主机目录/Home/home/user/rclone的水桶。我想在NextCloud Docker实例中访问此目录的内容。因此,我将其绑定到/var/www/html/数据。通过共享选项,容器中所做的任何更改都将反映在主机中,反之亦然。

我将/home/user/rclone的许可设置为777。可见内容可通过主机带有ls命令。重新启动Docker容器后,容器内部的LS命令将不会显示任何文件。 RCLONE仍在正确运行。

我怀疑,由于音量nextCloud安装在/var/www/html上,所以覆盖了bind安装的安装安装。

因此,我在容器中选择了另一个目录,即 /MNT并尝试了它。仍然没有使用ls命令显示的文件。

我的NextCloud Docker组成:( MySQL与此无关;仅显示/var/www/html/data Mount版本。)

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxx
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    network_mode: npm_default
    container_name: db

  app:
    image: nextcloud:latest
    restart: always
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
      - /home/user/rclone:/var/www/html/data:shared
    environment:
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - NEXTCLOUD_TRUSTED_DOMAINS=xxx
    network_mode: npm_default
    container_name: nextcloud

另一种放置它的方法:

rclone cloud Storage ->主持人 - > - > Docker ---> NextCloud外部存储

EDITED:

Rclone has a bucket mounted to the host directory /home/user/rclone. I want to access the contents of this directory inside nextcloud docker instance. So I would bind mount it to /var/www/html/data. With the option shared, any changes made in the container will be reflected in the host, and vice versa.

I have set the permission of /home/user/rclone to be 777. And the content is visible with a ls command from the host. Once the docker container is restarted, a ls command from within the container does not show any files. Rclone is still running properly.

I am suspecting that because the volume nextcloud is mounted at /var/www/html, the mount of the bind mount at /var/www/html/data is covered up.

So then I picked another directory inside the container, namely /mnt and tried it. Still no files show up with a ls command.

My nextcloud docker compose: (mysql does not have anything to do with this; showing the /var/www/html/data mount version only.)

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxx
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    network_mode: npm_default
    container_name: db

  app:
    image: nextcloud:latest
    restart: always
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
      - /home/user/rclone:/var/www/html/data:shared
    environment:
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - NEXTCLOUD_TRUSTED_DOMAINS=xxx
    network_mode: npm_default
    container_name: nextcloud

Another way of putting it:

rclone cloud storage --> host --> —> docker —-> nextcloud external storage

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蝶舞 2025-02-14 10:18:15

因此,NextCloud服务无法查看内容的原因是由于权限问题。

如果您执行exec -it NextCloud Bash检查内容,则它们在那里,因为您是root。

因此,如果要使用共享与主机目录绑定的安装座,则适当的解决方案是将权限设置为666,以便容器中的其他权限可以查看文件。

但是最后,我认为音量插件是一种更好的解决方案,因此这有点不弃用。

So the reason why the nextcloud service cannot view the content is due to permission problems.

If you do exec -it nextcloud bash to check the contents, they are there because you are root.

So the proper solution if you want to use a shared bind mount with the host directory, is to set permission to 666 so the others in the container can view the file.

But at the end, I have figured that volume plugins are a way better solution, thus this is somewhat deprecated.

漫漫岁月 2025-02-14 10:18:15

我遇到了这个问题,这是一个简单的原因。当我使用命令“ Docker Run -Mount Type = bind,src =”,dst“”时,我没有放置正确的路径。

确保检查SRC和DST路径以确保它们正确,并且只是绝对路径。即使这些值错误,码头容器也可以运行。

I was having this problem for a simple reason. I did not put the right path when I used the command "docker run --mount type=bind,src="",dst"" ".

MAKE SURE TO CHECK src, and dst paths to make sure they're right and are only absolute paths. The docker container can run even if these values are wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文