简体   繁体   English

更改 docker 创建的命名卷的权限

[英]altering permissions on docker-created named volumes

I'm attempting to use a docker volume to share data between two containers— where one container will write some data to the volume, and the other will read it.我正在尝试使用 docker 卷在两个容器之间共享数据——一个容器将一些数据写入该卷,另一个容器将读取它。

One of the constraints is that I will need to automate the process using docker-compose— so solutions where a user changes permissions from inside the container will not work其中一个限制是我需要使用 docker-compose 来自动化这个过程——所以用户从容器内部更改权限的解决方案将不起作用

how do i loosen the permissions for a shared volume managed by docker so that a process can write to it?如何放宽由 docker 管理的共享卷的权限,以便进程可以写入它?

for additional context: the data being written will be written by postgres, and will be read by a nest js app附加上下文:正在写入的数据将由 postgres 写入,并将由嵌套 js 应用程序读取

For now, my chosen workaround:目前,我选择的解决方法:

shared_volume_setup:
    image: alpine
    volumes:
      - postgres_exports:/tmp/exports
    entrypoint: [ "sh", "-c", "sleep 10 && chmod 777 /tmp/exports"] 

which spins up a different container with the sole purpose of altering the docker-managed volume它启动一个不同的容器,唯一的目的是改变 docker 管理的卷

I'm still seeking a better answer (using compose config on the volume rather than a separate workload container) but this works fine for now我仍在寻找更好的答案(在卷上使用 compose config 而不是单独的工作负载容器),但这目前工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM