bmaltais / kohya_ss

Apache License 2.0
8.79k stars 1.14k forks source link

Docker Container Approach -- Permission issues for generating BLIP captioning #2578

Closed BChip closed 1 week ago

BChip commented 3 weeks ago

Reproduce: git clone --recursive https://github.com/bmaltais/kohya_ss.git cd kohya_ss docker compose up -d

Upload a folder to the container with images for BLIP captioning ex: /app/outputs/my_new_folder_to_blip_caption Click caption images Watch logs in docker container and it will error out stating permission issues and it can't write *.txt to /app/outputs/my_new_folder_to_blip_caption.

When trying to do chmod +x my_new_folder_to_blip_caption it states you don't have permission to do this.

Any suggestions what to do?

jim60105 commented 3 weeks ago

chmod 775 , chgrp 0

kirby-jack commented 3 weeks ago

i tried chmod 775 <directory> and chgrp 0 <directory>

but no luck

jim60105 commented 2 weeks ago

Perhaps I should write a little more🤔

This image follows best practices by using non-root user. You have to ensure that all files mounted into it belong to root group and grant full permission for the group owner. https://docs.openshift.com/container-platform/4.15/openshift_images/create-images.html#use-uid_create-images

The container is running as 1000:0, and it may not have permission to execute chmod and chgrp commands in the container. If you want to correct the permission you can run it with sudo on the host, or start a busybox with root privileges to do this.

sudo docker run -v "{your_new_folder_to_blip_caption}:/app" -it busybox sh -c "chmod -R 775 /app && chgrp -R 0 /app"

[!Note] Please note that the above instructions are for docker, not podman. Podman is much more complex in handling permissions and requires different solution according to the situation.

And, check this out when dealing with SELinux https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label