# Write permissions on volume mount with security context fsgroup option

**URL:** <https://discuss.kubernetes.io/t/write-permissions-on-volume-mount-with-security-context-fsgroup-option/16524>\
**Category:** General Discussions\
**Created:** [June 30, 2021, 1:09pm UTC](https://discuss.kubernetes.io/t/write-permissions-on-volume-mount-with-security-context-fsgroup-option/16524 "2021-06-30T13:09:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![protosam](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/protosam/32/7732_2.png) [@protosam](https://discuss.kubernetes.io/u/protosam)\
**Post date:** [June 30, 2021, 2:16pm UTC](https://discuss.kubernetes.io/t/write-permissions-on-volume-mount-with-security-context-fsgroup-option/16524/2 "2021-06-30T14:16:24Z")

</div>

You’re troubleshooting file permissions. Remove your init container and try out the following. If you could provide this output it might also be useful in helping you.

Get a shell into the container.

```nohighlight
kubectl exec -it POD_NAME -- sh

```

Confirm your uid and gid.

```nohighlight
/ $ id
uid=1001 gid=1001 groups=1001

```

Test writing to the directory.

```nohighlight
/ $ echo test > /opt/var/logs/docker/test.txt 
/ $ cat /opt/var/logs/docker/test.txt
test

```

Walk the directory and confirm permissions along the directory.

```nohighlight
/ $ ls -lah /opt /opt/var /opt/var/logs /opt/var/logs/docker/
/opt:
total 12K    
drwxr-xr-x 1 root root 4.0K Jun 30 14:06 .
drwxr-xr-x 1 root root 4.0K Jun 30 14:06 ..
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 var

/opt/var:
total 12K    
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 .
drwxr-xr-x 1 root root 4.0K Jun 30 14:06 ..
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 logs

/opt/var/logs:
total 12K    
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 .
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 ..
drwxrwsr-x 3 root 1001 4.0K Jun 30 14:07 docker

/opt/var/logs/docker/:
total 28K    
drwxrwsr-x 3 root 1001 4.0K Jun 30 14:07 .
drwxr-xr-x 3 root root 4.0K Jun 30 14:06 ..
drwxrws--- 2 root 1001 16.0K Jun 30 13:58 lost+found
-rw-r--r-- 1 1001 1001 5 Jun 30 14:14 test.txt

```

---

_[View the full topic](https://discuss.kubernetes.io/t/write-permissions-on-volume-mount-with-security-context-fsgroup-option/16524)._
