Docker in docker Write to folder Permission denied

Hello, I run docker in docker based on [1]. I try to run the ready docker inside the docker ( outer docker is opened as the dev container in vs code).

The inner container needs to read some files and, on this basis, write the output.
It can successfully read files and run but gives an error at the moment it needs to write the output.

File cannot be written: /output/images/transverse-whole-prostate-mri/.tmp.prostate_gland.mha
Reason: Permission denied

I run outer docker as privileged

The inner docker I run like below

sudo docker run --init --ipc host --cpus=8 --privileged --memory=12gb --shm-size=12gb --gpus='"device=0"' -it\
    -v /media/jm/hddData/datasets/for_pic/data/for_picai_docker/test/:/input \
    -v $HOME/data/picai_output/:/output/ \

I tried to set broadest possible permissions to the folder from outer docker

sudo chown -R "$USER":"$USER" $HOME/data/picai_output/

but still error persist. The problem is not happening when I run the inner docker from system - so container is ok.

Thanks for any help !

1)GitHub - Henderake/dind-nvidia-docker: nvidia-docker in DinD (Docker inside Docker)