Docker Bind Mount的内容未显示在容器内部
编辑:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,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 to666
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.
我遇到了这个问题,这是一个简单的原因。当我使用命令“ 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.