0 1 How to set permission on Volume mount

0

In my CDK app I have an ElasticSearch docker that starts on an EC2 instance and on start up it cannot write to the host path's Volume mount point directory which I set to /mnt/data/elasticsearch/ so the container stops,
The reason is the permissions on the directory when the instance is starts is 755. When I SSH into the instance and change it to 777 the container starts up and continues on without issue.

This is how I create the volume and mount point

 import software.amazon.awscdk.services.ecs.Volume  
  
 auto_scaling_groupp.addUserData("sudo chmod -R 777  /usr/share/elasticsearch/data);` // This has no effect   
  
 Volume hostVolume =  Volume.builder().name("elasticsearch").host(Host.builder()  
                         .sourcePath(/mnt/data/elasticsearch).build()).build();  
   
MountPoint elasticSrvrMntPt = MountPoint.builder().readOnly(false).sourceVolume(hostVolume.getName())  
                .containerPath("/usr/share/elasticsearch/data").build();  
  
ElasticDef.addMountPoints(elasticSrvrMntPt);  

I cannot find in the API how to either give permission to that container or change the permission on the folder
Thanks

Edited by: sdiventura on Apr 9, 2021 2:16 PM

질문됨 3년 전1117회 조회
1개 답변
0

The reason is because I was using a bind mounts to mount at container, By default, the volume permissions are set to 0755 and the owner as root. The permissions would need be changed in the Elastic Dockerfile. Instead I used Volume to mount the host dir
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bind-mounts.html

답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠