I need to mount a folder inside a docker container with specific permission for the folder and the files inside it (700 for the folder and 600 for the files). It is not enough to mount the folder with the 'rw directly under the service section since some programs specifically require permission to be 700 and 600.
Now I am trying to declare the volumes in docker-compose.yml as follows, but it gives me an error when turning up the container.
docker-compose.yml
services:
laravel.test:
volumes:
- 'ssh-credentials:/root/.ssh'
volumes:
ssh-credentials:
driver: local
driver_opts:
o: bind,dir_mode=0700,file_mode=0600
type: none
device: ./.ssh
The error returned is the following:
Error response from daemon: error while mounting volume '/var/lib/docker/volumes/example-app_ssh-credentials/_data': failed to mount local volume: mount ./.ssh:/var/lib/docker/volumes/example-app_ssh-credentials/_data, flags: 0x1000, data: dir_mode=0700,file_mode=0600: no such file or directory