Greengrass/Docker local volume permissions

0

I have a greengrass component that runs a docker container, I am struggling to understand how the permissions of folders and file are set when this is run by greengrass.

A snippet of my recipe looks like this:

"Install": {
          "Skipif": {
            "exists": "/home/ggc_user/data/package.json"
          },
          "Script": "mkdir -m 777 /home/ggc_user/data"
        },
        "Run": {
          "Script": "docker run --restart always -v /home/ggc_user/onwatch-data:/home/node/.signalk --log-opt max-size=10m --log-opt max-file=5  --network host --name testContainter testContainer"
        }

When I look at the permissions of /home/ggc_user/ using ls -l after the component is installed the file permissions look like:

drwxrwxrwx 4 ggc_user ggc_group 4096 Oct 6 15:38 data

I then go into the 'data' directory and look at the permissions of the files created inside from the docker container and the files are owned by admin which is my standard user.

-rw-r--r-- 1 admin admin   186 Oct  6 15:33 package.json
drwxr-xr-x 2 admin admin  4096 Oct  6 15:33 plugin-config-data

I would have thought it would create these with ggc_user as the owner. I have issues getting the container to run unless I set the permissions to 777.

What am I doing wrong?

질문됨 2년 전219회 조회
3개 답변
1

Hi Phil,

This is just the normal behaviour of Docker on Linux and has nothing to do with Greengrass. Files written to an host mounted volume have the owner set to the user running the process the container. In your case, as the container runs with the user admin:admin, any file written to the host will have the same ownership.

I do not know which issues you are encountering in running your container, but you can try to run the component as admin:admin so that the user running in the container matches the user on the host.

You can set the uid and gid for the component in the deployment configuration.

Cheers,

Massimiliano

AWS
전문가
답변함 2년 전
1

You might consider setting the "runWith" parameter in your component recipe. For more information, see the "runWith" property description at https://docs.aws.amazon.com/greengrass/v2/developerguide/create-deployments.html

AWS
dghz
답변함 2년 전
0

Inside the Dockerfile the user and group created was GID:1000 UID:1000, which is the same as my admin user on the host. I have changed the component to run as admin and the permission errors have gone away.

답변함 2년 전

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

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

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

관련 콘텐츠