请问,我用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, 在容器中没有权限在该目录下新建文件。请问如何解决这个问题?
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-compose
的volumes:
partial definition:can solve the problem you mentioned.