Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Compose Make Shared Volume Writable Permission Denied

I have this image that writes into the /temp/config and I wanted to map those data into a shared volume in my host

docker-compose downversion: '2'

services:
  service-test:
    image: service-test:latest
    container_name: service-test
    volumes:
      - source_data:/temp/config/

volumes:
    source_data:

When my service-test:latest image tries to write into the /temp/config, I am getting a Permission Denied error.

Question, how do I make this host shared volume writable?

I checked the shared volume using

docker volume inspect source_data

and I noticed that it has no write functionality. This is a linux based distro.

UPDATE 2: To verify this, I tried checking the permissions on the shared volume and I noticed that it has no write permissions also.

bash-4.2$ docker inspect volume service-test_source_data
[
    {
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/scratch/docker/volumes/service-test_source_data/_data",
        "Name": "configservice-test_config_data",
        "Options": {},
        "Scope": "local"
    }
]

bash-4.2$ ls -l /scratch/docker/volumes/service-test_source_data/
**drwxr-xr-x** 1 root root 0 Apr 18 01:43 _data
like image 425
Mark Estrada Avatar asked Apr 19 '18 08:04

Mark Estrada


1 Answers

I believe your container is running as some specific user other than root.

In your docker-compose.yml you can add user: root
See docker-compose-reference

like image 111
fly2matrix Avatar answered Sep 28 '22 07:09

fly2matrix