golang - docker volume挂载不存在的主机目录到容器时,自动创建的目录的权限为root
伊谢尔伦
伊谢尔伦 2017-04-22 08:58:56
0
1
698

请问,我用docker volume时,挂在本地目录到容器目录。如果本地目录不存在,docker会自动创建一个。比如:
docker run --name=node-1 --rm=true --volume=/home/simba/work/test:/home/jovyan/work --publish=:8888 --publish-all=false jupyter/all-spark-notebook
当test用户不存在时,docker会自动创建test.然而自动创建的test的权限是drwxr-xr-x 2 root root, 在容器中没有权限在该目录下新建文件。请问如何解决这个问题?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
大家讲道理

In the situation you mentioned, Docker’s data volume should be used. In Swarm, you should not use the method of mounting the host directory to save data.

Create the required data volume in the Swarm environment, and then the container can use the data volume. Can use docker volume create mydata 来创建数据卷,然后在挂载时使用 -v mydata:/opt/data,或者直接在 docker-composevolumes: partial definition:

volumes:
    mydata:{}

can solve the problem you mentioned.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!